How can i make a ui teleport the player too a part when its clicked

pretty simple i want a ui to teleport the player to a part

1 Like

Make a button
and add a localscript into the button.

local Player = game.Players.LocalPlayer
local YourPart = -- Your Part Path Here
script.Parent.MouseButton1Click:Connect(function()
Player.Character.HumanoidRootPart.CFrame = YourPart.CFrame
end)

not position you should use CFrame btw

You need to use CFrame

Player.Character.HumanoidRootPart.CFrame = CFrame.new(YourPart.Position)

add a local script inside of this Button
Change yourpart to your Part name

script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Workspace.YourPart.CFrame
end)

You forgot CFrame.new()

game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.YourPart.Position)

no you could just do HRP.CFrame = Part.CFrame

There is no need for it when you could do

game.Workspace.YourPart.CFrame

oh it’s interesting to know that I didn’t know about it (even if when you think about it it’s logical)

Use PivotTo() on the Character model to move the Player instead.

it doesnt seem to work

Change YourPart to your part in workspace.

i did it still doesnt work

Can I see your script?

did you try my script?
Chars Limit

yes i tried yours i also doesnt work

make sure its a localscript + inside a GUI Button.

hmm i was trying to fix it but heres my script

script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Workspace.SpawnPart.CFrame
end)

yes its a local script its inside an imagebutton

is it showing an errors in the output?