Need help with teleporting a part to the LocalPlayer's HumanoidRootPart

I need help with a script which makes a part teleport to the localplayer’s humanoidrootpart when a GUI button is pressed. I’ve tried to do this many times but I just can’t seem to figure out how to do it, can someone help me please? Thanks.

Are you trying to it locally or server sided?

You could move the part’s CFrame to the rootpart’s CFrame which should be the solution

Example

local part = --Your part location

local button = script.Parent

local player = game.Players.LocalPlayer

local char = player.Character or player.CharacterAdded:Wait()

button.MouseButton1Clicked:Connect(function()
	part.CFrame = char.HumanoidRootPart.CFrame
end)

Note: This only works for you as it’s client sided, if you want it to show for everyone, you’d have to use RemoteEvents

Great, thanks I will try this out.

It isn’t working? I’m not sure what I’m doing wrong. I put the script inside of a localscript and it didn’t work, i tried a normal script but that didn’t work either.

Put the code I mentioned as a localscript in the GuiButton. It wont work as a regular script since there’s LocalPlayer, I’m not sure if it’s not working because you have to do it Remotely or cause of the CFrame. Maybe try instead of

part.CFrame = char.HumanoidRootPart.CFrame

To

part.CFrame = char.HumanoidRootPart.CFrame.LookVector * 5

I did that already? I tried the LookVector * 5 but that didn’t work neither. I don’t know why :confused:

te

Ohh wait I see the issue, wrong event

MouseButton1Clicked is supposed to be MouseButton1Click

I’m terribly sorry if I wrote it wrong

Thank you so much! I’ve been trying to figure this out for ages, life saver!

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

1 Like