So I have this script here that teleports a player, but the only issue is, it doesn;t when I play the game; only when I test in studio does it work. It is a regular script and I am not sure what I should try. Anyone have any insight?
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | local TeleportTo = game.Workspace:FindFirstChild( "Tp2" ) |
3 | local Player = script.Parent.Parent.Parent.Parent |
4 | local Character = Player.Character |
5 | local Torso = Character:WaitForChild( "Torso" ) |
6 | Torso.CFrame = TeleportTo.CFrame * CFrame.new( 0 , 0 , 20 ) |
7 | end ) |
You can’t use a server (regular) script in GUI like this. Testing solo in studio works because I guess testing mode combines client and server, making your script work in-studio.
I forgot if you can change CFrame on a player with a localscript so change the server script into a localscript, and if that doesn’t work, use RemoteEvents, which you can read about here.