function getPlayerNumberInTeam(TeamColor)
local num = 0
for index,player in pairs(game.Players:GetChildren()) do
if tostring(player.TeamColor) == TeamColor and not player.Neutral then
num = num+1
end
end
return num
end
print(getPlayerNumberInTeam(tostring(game.Teams.Dead.TeamColor)))
wait(1)
local debounce = true
while debounce == true do
if getPlayerNumberInTeam(tostring(game.Teams.Death.TeamColor)) == 0 or getPlayerNumberInTeam(tostring(game.Teams.Runners.TeamColor)) == 0 then
debounce = false
wait()
end
wait()
end
for i, player in ipairs(game.Players:GetChildren()) do
player.TeamColor = game.Teams["Dead"].TeamColor
player.Character:MoveTo(game.Workspace.SpawnLocation.Position + Vector3.new(0, i * 5, 0))
end
end
Ok, so it's easier for people to help me with this, I will explain what every part of the script does (or at least what it's supposed to do).
function getPlayerNumberInTeam(TeamColor)
local num = 0
for index,player in pairs(game.Players:GetChildren()) do
if tostring(player.TeamColor) == TeamColor and not player.Neutral then
num = num+1
end
end
return num
end
This is a function that gets the number of players in a certain team that you input the color of post-function script.
print(getPlayerNumberInTeam(tostring(game.Teams.Dead.TeamColor)))
This will use the function to print the number of players in the team color or teamname.teamcolor that you insert at the end of the command there.
local debounce = true
while debounce == true do
if getPlayerNumberInTeam(tostring(game.Teams.Death.TeamColor)) == 0 or getPlayerNumberInTeam(tostring(game.Teams.Runners.TeamColor)) == 0 then
debounce = false
wait()
end
wait()
end
This is supposed to wait until there aren't any players in one of the two teams: Death or Runners
for i, player in ipairs(game.Players:GetChildren()) do
player.TeamColor = game.Teams["Dead"].TeamColor
player.Character:MoveTo(game.Workspace.SpawnLocation.Position + Vector3.new(0, i * 5, 0))
end
It should then put everyone in the team "Dead" and teleport them to the spawn point.
The script makes it up to the part where it checks Death and Runners for players, but then it doesn't do anything. Some help?

2 comments
could you explain more? What do you mean by "It does things and works fine if I set one of the teams to Dead, but otherwise it doesn't work."?
Sorry, I fixed it. That part should've been there, it didn't make sense and I'm not sure why I typed that.