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))) while getPlayerNumberInTeam(tostring(game.Teams.Dead.TeamColor)) ~= 0 or getPlayerNumberInTeam(tostring(game.Teams.Runners.TeamColor)) ~= 0 do getPlayerNumberInTeam() 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
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.
while getPlayerNumberInTeam(tostring(game.Teams.Death.TeamColor)) ~= 0 or getPlayerNumberInTeam(tostring(game.Teams.Runners.TeamColor)) ~= 0 do getPlayerNumberInTeam() 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 gets up to the point where it prints how many people are in the specified team, it won't go further than that. Someone help me with this?
Perhaps you can try this to have the while loop run at the same time as the code below:
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))) spawn(function() while getPlayerNumberInTeam(tostring(game.Teams.Dead.TeamColor)) ~= 0 or getPlayerNumberInTeam(tostring(game.Teams.Runners.TeamColor)) ~= 0 do getPlayerNumberInTeam() wait() end 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