Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question