The script is supposed to teleport players based on their teams after they spawn when a certain value becomes true.
However, the script is not doing anything, and Output has given me nothing. I have no idea what the problem is. Can someone please help me?
Here's the script:
local Playing = game.ServerScriptService.MainGameScript.Variables:WaitForChild("Playing")
local Player = game.Players.LocalPlayer
local TeleVal = Player:WaitForChild("Teleported")
local Map = game.ServerScriptService.MainGameScript.Variables:WaitForChild("Map")
while wait(0.1) do
if Playing.Value == true and TeleVal.Value == false and Map.Value ~= " " then
local Thingy = game.Workspace:WaitForChild("Map")
BB = {}
DD = {}
GG = {}
RR = {}
local Spawns = Map:WaitForChild("Spawns")
local BBS = Spawns:WaitForChild("BBS")
local DDS = Spawns:WaitForChild("DDS")
local GGS = Spawns:WaitForChild("GGS")
local RRS = Spawns:WaitForChild("RRS")
for i,v in ipairs(BBS:GetChildren()) do
if v.Name == "Spawn" then
table.insert(BB,v)
end
end
for i,v in ipairs(DDS:GetChildren()) do
if v.Name == "Spawn" then
table.insert(DD,v)
end
end
for i,v in ipairs(GGS:GetChildren()) do
if v.Name == "Spawn" then
table.insert(GG,v)
end
end
for i,v in ipairs(RRS:GetChildren()) do
if v.Name == "Spawn" then
table.insert(RR,v)
end
end
TeleVal.Value = true
if Player.TeamColor == BrickColor.new("Bright red") then
Player.Character.Humanoid:MoveTo(RR[math.random(1,#RR)].Position)
elseif Player.TeamColor == BrickColor.new("Bright blue") then
Player.Character.Humanoid:MoveTo(BB[math.random(1,#BB)].Position)
elseif Player.TeamColor == BrickColor.new("Bright yellow") then
Player.Character.Humanoid:MoveTo(DD[math.random(1,#DD)].Position)
elseif Player.TeamColor == BrickColor.new("Bright green") then
Player.Character.Humanoid:MoveTo(GG[math.random(1,#GG)].Position)
end
end
end

4 comments
Local scripts cant access server script service.
I changed it, and it still doesn't work
Can you print something under line 7 to see if it actually executes?
It does not execute, I've tried that. I've decided to use spawns for the game instead