Teleport whenever button pressed

Hello, can someone help with a script? All help is appreciated. I have a little lobby, and I need it so whenever players hit the PlayButton UI button, the players teleport to a location on the map. The script will be inside of a local script inside of PlayButton.

You can teleport players locally and they will replicate to the server(this is because they have network ownership of their player).

To achieve your goal, you have to connect a MouseButton1Click event, which basically detects when the player presses the button, and releases it on the button. Then, you would teleport the players character using MoveTo() or SetPrimaryPartCFrame.

1 Like

You can make a remotevent that fires the server when a client clicks on the button, teleporting on the server is better than teleporting on the client side

How would it be better? Handling on the client would keep the code simple and as @VegetationBush had mentioned the position of players will replicate to the server so it won’t cause any issue.