Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to move parts to or near a players position?

So I know basic scripting and I'm practising to script by making an admin gui and one of the options I want on it is a "Jail Player" option, but how do teleport the jail to player so that the target is trapped inside and cant get out.

1 answer

✓ Accepted answer

You can move their HumanoidRootPart.

local Dummy = workspace:WaitForChild("Dummy") -- There's a dummy in the workspace for example

Dummy.HumanoidRootPart.CFrame = CFrame.new(workspace.Part.Position)
-- We're changing the RootPart's CFrame to a Part (in workspace)'s Position

5 comments

0

Nice Answer !

0

Yea beated me to it and your answer is nice so I will up vote you.

1

Regular Scripts don't normally require WaitForChild. You can also use :SetPrimaryPartCFrame(), it's redundant to adjust a CoordinateFrame if the CFrame is constructed with position only (you could've just used :MoveTo(Vector3)

0

If the jail is too small, :SetPrimaryPartCFrame is ideal as :MoveTo moves the Model upwards until there is nothing obstructing it on the Y axis. Usage of :SetPrimaryPartCFrame can be justified.

0

Ima need this explaining to me, does anyone have a discord

This discussion is preserved as it was. New answers, comments, and votes are closed.