I am trying to count the number of people on a green team and a blue team and place them in 2 different values named "a" and "b." Can someone help me out? I don't exactly have a code yet because I don't know how I would be able to set this up.
function CountPlayers(teamcolor) local count=0; for i,v in next,Game.Players:GetPlayers() do if v.TeamColor==teamcolor then count=count+1 end end return count; end --EXAMPLE: print(CountPlayers(BrickColor.new("Bright red")))
local a={} local b={} for _,v in pairs(game.Players:GetPlayers())do if v.TeamColor==BrickColor.new("Bright green")then a[#a+1]=v else b[#b+1]=v end end
Checks each player's team color and adds their player to table a
if their TeamColor is Bright green or b
otherwise.