|
| 25 Jun 2015 11:17 AM |
It worked fine with 2 teams, but I'm not sure how to make it work with 4. I've tried many different ways. It also says I can't have more than one else in the statement, which I tried as well.
function shuffle(Table) local n, random, j,k = #Table, math.random for i=1, n do j,k = random(n), random(n) Table[j],Table[k] = Table[k],Table[j] end return Table end shuffle(players)
for i,v in ipairs(players) do if i % 2 == 0 then v.TeamColor = BrickColor.new("Bright red") else v.TeamColor = BrickColor.new("Bright blue") ----------------I added bright green and yellow, didn't change anything with the working red and blue scrambler v.TeamColor = BrickColor.new("Bright green") v.TeamColor = BrickColor.new("Bright yellow") end end |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 25 Jun 2015 11:28 AM |
function shuffle(Table) local n, random, j,k = #Table, math.random for i=1, n do j,k = random(n), random(n) Table[j],Table[k] = Table[k],Table[j] end return Table end shuffle(players)
local colors = {"Bright red", "Bright blue", "Bright green", "Bright yellow"} for i,v in ipairs(players) do v.TeamColor = BrickColor.new(colors[i % 4]) end |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 11:57 AM |
function Organize(List, Players) for Index = 1, #Players do table.remove(Players, math.random(#Players)).TeamColor = List[Index % #List + 1] end end
Organize({"Bright red", "Bright blue", "Bright green", "Bright yellow"}, game.Players:GetPlayers()) |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 11:58 AM |
| lord that worked, thank you |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 12:03 PM |
Just posting because there is an error in my script (I know you have your solution):
function Organize(List, Players) for Index = 1, #Players do table.remove(Players, math.random(#Players)).TeamColor = BrickColor.new(List[Index % #List + 1]) end end
Organize({"Bright red", "Bright blue", "Bright green", "Bright yellow"}, game.Players:GetPlayers()) |
|
|
| Report Abuse |
|
|