Hello, I'm trying to code a Player Teleportation script for an OnClicked Gui to teleport to my game. The code is below.
function OnClicked() script.Disabled = true local player = script.Parent.Parent.Parent.Parent if player then game:GetService("TeleportService"):Teleport(361416851, player) end end script.Parent.MouseButton1Click:connect(OnClicked)
Why does this not work in a game? If someone can help me, that'd be great!
You're trying to shut down the script before you can do anything. Move line 2 down to line 5 and it should work. Good luck!