Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I keep two teams from having the same random teamcolor?

Asked by
wrenzh 65
11 years ago

What I'm trying to do is make a new team for every player that enters and have that team's name be the Player's name with a random TeamColor.

I can use BrickColor.Random() to find a random color for the Team, but how do I ensure (and still end up with a new team) that no two teams have the same color?

1 answer

Log in to vote
1
Answered by 11 years ago
1local color1 = BrickColor.Random()
2Team1.TeamColor = color1
3 
4local color2 = BrickColor.Random()
5while color2 == color1 do
6color2 =  BrickColor.Random()
7end
8 
9Team2.TeamColor = color2
0
Will this function no matter how many teams eventually end up in the game? wrenzh 65 — 11y
0
Yes. Just repeat it for all the teams. User#2263 0 — 11y
Ad

Answer this question