Gui Teleport Button Not Working

I’ve created a script that is meant to teleport a player to another game but when I run the code it says “Invalid Player to Teleport.” I do not understand what I did wrong in the script.

Here’s the script:

local GameID = 4019852350
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()

game:GetService("TeleportService"):Teleport(GameID, Player)

end)

Is this a local script? or a Server Script. If it’s a local script it needs to fire server to be teleported.

If you’re testing it in studio, you’re unable to teleport within studio.

It is a server script, I believe.

I’ve tested it in outside of studio and it still didn’t work.

Then there is an issue as you are using game.Players.LocalPlayer which is only accessible by the client. This would explain why the server can not teleport the supposed player.

Ah, I see now. Thank you for your help.

1 Like

Thx bro its really work)) thank you for your help!