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
10 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 10 years ago
local color1 = BrickColor.Random() 
Team1.TeamColor = color1

local color2 = BrickColor.Random() 
while color2 == color1 do
color2 =  BrickColor.Random() 
end

Team2.TeamColor = color2
0
Will this function no matter how many teams eventually end up in the game? wrenzh 65 — 10y
0
Yes. Just repeat it for all the teams. User#2263 0 — 10y
Ad

Answer this question