|
| 15 May 2016 10:59 AM |
In studio I have 3 teams: -Lobby -Red -Blue
Everyone is in the lobby team. I need a script to make every player go into either red or blue team. The red and blue team has to have an equal amount of players!
|
|
|
| Report Abuse |
|
|
Salinas23
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 37142 |
|
|
| 15 May 2016 11:03 AM |
1) find how many players are in the server 2) pick one random player, and make its team red 3) repeat until half of the server players are in team read 4) blue team will consist of those left in lobby |
|
|
| Report Abuse |
|
|
|
| 15 May 2016 11:09 AM |
May I have a script please?
|
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 15 May 2016 11:15 AM |
local teams = {"Bright red","Bright blue","Black"} --change these to colors of team for i,v in pairs(game.Players:GetPlayers()) do v.TeamColor = teams[(i%3)+1] end |
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 15 May 2016 11:16 AM |
| didn't read post lol remove lobby color from table and change the second number in the modulus equation to 2 |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2016 11:27 AM |
Nvm, that didn't work for some reason.
|
|
|
| Report Abuse |
|
|
|
| 15 May 2016 11:27 AM |
Is it correct? local teams = {"Bright red","Bright blue"} for i,v in pairs(game.Players:GetPlayers()) do v.TeamColor = teams[(i%2)+1] end
|
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 15 May 2016 11:31 AM |
| Yep, make sure the two colors in the table are the EXACT same as the two teamcolors (same caps, spelling, spaces, etc) |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2016 11:33 AM |
Should I used BrickColor.new?
|
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 15 May 2016 11:33 AM |
| oh, duh, you need to put the table values as brickcolor values not string values, my bad |
|
|
| Report Abuse |
|
|
|
| 15 May 2016 11:35 AM |
So how should I do it? local teams = ??? for i,v in pairs(game.Players:GetPlayers()) do v.TeamColor= ??? end
|
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 15 May 2016 11:36 AM |
leave line 4 as it is,
change the table values
local teams = {BrickColor.new("Bright red"),BrickColor.new("Bright blue")} |
|
|
| Report Abuse |
|
|