Hi. I am trying to make a code. When It's executed, It makes half of the players in red team, other half of the players in blue team. How can I do it?
Here is an example. (It's example only. It isn't working)
function setTeams() local firstHalf = someCode local secondHalf = someOtherCode for i, v in pairs(firstHalf) do v.TeamColor = BrickColor.new('Bright red') v:LoadCharacter() end for i, v in pairs(secondHalf) do v.TeamColor = BrickColor.new('Bright blue') v:LoadCharacter() end end
As I said, It's just an example. It isn't working.
How can I do it?
I did it. It basically uses 1 variable.
local red = true for i, v in pairs(game.Players:GetChildren()) do if red == true then v.TeamColor = BrickColor.new('Bright red') red = false elseif red == false then v.TeamColor = BrickColor.new('Bright blue') red = true end v:LoadCharacter() end
It simply does 1 red, 1 blue, 1 red, 1 blue .........
Thanks everybody.