This spawning script is supposed to detect if a value in a player is false and if a value in Workspace is true. If that is the case, the script is supposed to teleport the player if and only if that is the case.
However, even if the value in Workspace is false, the script still teleports players. I have no idea why it is doing this, as output didn't give me anything.
Can someone please help me? Here's the script:
local Player = script.Parent.Parent
local Started = game.Workspace:WaitForChild("Go")
while wait(0.1) do
if Started.Value == true then
if Player.PlayerGui.Teleported.Value == false then
Player.PlayerGui.Teleported.Value = true
local torso = Player.Character.Torso
local spawns = {}
if Player.TeamColor == BrickColor.new("Bright blue") then
for i,v in ipairs(game.Workspace.Map.Humans:GetChildren()) do
if v.Name == "Spawn" then
table.insert(spawns,v)
end
end
if Player.Lethals ~= nil then
local children = Player.Lethals:GetChildren()
for i = 1, #children do
children[i].Value = 2
end
end
torso.CFrame = spawns[math.random(1,#spawns)].CFrame + Vector3.new(0,4,0)
elseif Player.TeamColor == BrickColor.new("Bright red") then
for i,v in ipairs(game.Workspace.Map.Zombies:GetChildren()) do
if v.Name == "Spawn" then
table.insert(spawns,v)
end
end
if Player.Lethals ~= nil then
local children = Player.Lethals:GetChildren()
for i = 1, #children do
children[i].Value = 2
end
end
torso.CFrame = spawns[math.random(1,#spawns)].CFrame + Vector3.new(0,4,0)
end
end
end
end

2 comments
To check if something exists or not, you have to use :findFirstChild() -- where you have Player.Lethals. Also try using pairs instead of ipairs. Another thing: Use SpawnLocations. They will work the same way.
Try doing '~=' on the ifs.