This script is a local script. It works in studio but will not work online. I really don't understand why.
local player = game.Players.LocalPlayer
local inMap = true
script.Parent.TeleportButton.MouseButton1Click:connect(function()
local toRange = workspace.TargetSpawn.Position
local team = nil
-- 0 = blue
-- 1 = red
local TeamSpawn = nil
if player.TeamColor == game.Teams.Alpha.TeamColor then
team = 0
else
team = 1
end
if team == 0 then
TeamSpawn = workspace.Blue.Position
elseif team == 1 then
TeamSpawn = workspace.Red.Position
end
wait(0.5)
if inMap then
player.Character:MoveTo(toRange)
inMap = false
elseif (not inMap) then
player.Character:MoveTo(TeamSpawn)
inMap = true
end
end)

2 comments
Where is the localscript located? Are there any errors?
Local script. No errors. The script works on studio but not in a game server. The local script is located inside the gui in starter gui.