Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ModelName = 'NPC' -- The name of the model to be moved
- local ModelToMove = workspace:FindFirstChild(ModelName) -- Model must be in Workspace for this to work
- local CFrameParts = ModelToMove.CFrameParts
- local Main = ModelToMove.Main
- local CFP1 = CFrameParts.CFramePart1 -- CFramePart1 (Will be used for getting the Original Position)
- local CFP2 = CFrameParts.CFramePart2 -- CFramePart2 (Getting the position to where the model will move to)
- local OrignialPosition = CFP1.CFrame -- Here we get the CFrame
- local SetPosition = CFP2.CFrame -- Gets CFrame ("Position") of the block where the model will move which is "CFramePart2"
- CFP1:Destroy() -- We get rid of them because they are useless now that we have the CFrame for them!
- CFP2:Destroy()
- ModelToMove.PrimaryPart = Main --[[ Sets the model's PrimaryPart so we can use :SetPrimaryPartCFrame() which will be ..
- helpful for moving the model as a whole ]]
- local Touched = false -- Debounce
- script.Parent.Touched:Connect(function(hit)
- if hit.Parent:FindFirstChild('Humanoid') then
- if Touched == false then
- Touched = true
- ModelToMove:SetPrimaryPartCFrame(SetPosition) --[[ The code is saying; when you have touched the block, it will ..
- move and never work again in this server because of the debounce]]
- wait(5)
- ModelToMove:SetPrimaryPartCFrame(OrignialPosition) -- Moves to original position
- Touched = false
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement