so I'm making a game with 2 places so I'm attempting to make a teleport that allows you to go between the too buy touching the part here's the script the game is published and the game id is correct any solutions? I tried other scripts but nothing worked.
local TeleportService = game:GetService("TeleportService")
local gameID = 5432114105
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
TeleportService:Teleport(gameID, player)
end
end
script.Parent.Touched:connect(onTouched)

6 comments
Ensure you're using a Server-sided Script; workspace is a global environment, localized programs will not function there.
i dont understand lol
Use a regular Script, not a LocalScript.
i did
You can't teleport in the Studio either.
Also dont use
connectbut useConnectinstead,connectis deprecated