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

How to teleport player when Gui button clicked??

Hi I have a Gui button that I want the player to teleport to a part when click. But it doesn't work. I have tried putting the teleport script in the Gui button. It didn't work so I tried to send a remote event to severscriptservice to teleport the player still don't work. The remote event is named TP and the scripts are just scripts. Gui button script:

script.Parent.MouseButton1Click:Connect(function(player)



	game.ReplicatedStorage.TP:FireClient()



end)

ServerScriptService Script:

game.ReplicatedStorage.TP.OnServerEvent:Connect(function(player)

	player.Character.HumanoidRootPart.Position = workspace.CarSpawnPlayer.Position	

end)

1 answer

✓ Accepted answer
player.Character.HumanoidRootPart.CFrame = workspace.CarSpawnPlayer.CFrame  

you need to use CFrame when moving humanoids because they have all these Motor6Ds and attachments, joints, moving Position won't update the constraints which will kill the humanoid i think or just won't move it... also you have a typo i guess:

game.ReplicatedStorage.TP:FireClient()
-- ^^^ noe
game.ReplicatedStorage.TP:FireServer()

i don't know for sure but i think you don't even need the remote event since specially applies to humanoid, moving humanoid locally will replicate it to all other players automatically.

5 comments

0

Hi I did all the fixes you suggested I keep receiving an error error code: FireServer can only be called from the client.

0

Oh crap hi Kirda

0

????

0

the script in the button must be localscript!!!!!!!!!!!!!!!!!!!!!!!!!!!

0

Thank you this helps me a lot!!

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