How do you divide team red, and blue evenly with players? Can somebody give me an example in code, and explain what each part of code does?
✓ ANSWER ACCEPTED
How do you divide teams evenly?
1 answer
✓ Accepted answer
Answered it here: How do I make this spread the teams equally?
rval = 0 -- a value to count players in red team
bval = 0 -- in blue team
for i, player in pairs(game.Players:GetPlayers()) do -- get the players
if rval < bval then -- if one has more players than the other
player.TeamColor = BrickColor.new("Bright red")
rval = rval + 1 -- adding the player to the value
elseif rval > bval then -- the inverse
player.TeamColor=BrickColor.new("Bright blue")
bval = bval + 1
else -- if they're equal
player.TeamColor = BrickColor.new("Bright red")
rval = rval + 1
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
