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

Why would a script from a GUI work in studio but not in actual game?

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?

script.Parent.MouseButton1Click:connect(function()
	local TeleportTo = game.Workspace:FindFirstChild("Tp2")
	local Player = script.Parent.Parent.Parent.Parent
	local Character = Player.Character
	local Torso = Character:WaitForChild("Torso")
	Torso.CFrame = TeleportTo.CFrame * CFrame.new(0,0,20)
end)

1 answer

✓ Accepted answer

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.

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