|
| 27 Aug 2014 04:40 PM |
So this team randomizer I made works fine, but the thing is with it being random it will be unequal most of the time, so I need you guy's help to make it so it will always be equal.
while true do wait(1) for i,v in pairs(Game.Players:GetPlayers()) do team = {"Bright yellow", "Dark stone grey"} v.TeamColor = BrickColor.new(team[math.random(#team)]) end wait(3) for i,v in pairs(Game.Players:GetPlayers()) do v.TeamColor = BrickColor.new("White")
end
end
|
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 27 Aug 2014 04:42 PM |
hey!:) what i would do is check the numbers on each team if equal then do a random if one is more than the other then put that player on the team will less players
want me to try that for you? |
|
|
| Report Abuse |
|
|
ROBOFROG
|
  |
| Joined: 04 Jan 2009 |
| Total Posts: 1519 |
|
|
| 27 Aug 2014 04:44 PM |
This may not be the best and most efficient way, but it'll work.
Create an integer value for each team, and check if they are equal to one another. If not, have it increase the lowest value's team by one until all players are sorted. |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2014 04:44 PM |
It would be great if you could try it for me <3
|
|
|
| Report Abuse |
|
|
tyzone
|
  |
| Joined: 16 Aug 2008 |
| Total Posts: 1726 |
|
|
| 27 Aug 2014 04:55 PM |
if i ~= #game.Players:GetPlayers() or #game.Players:GetPlayers()%#team ~= 0 then v.TeamColor = BrickColor.new(team[(i%#team+)1]) else v.TeamColor = BrickColor.new(team[math.random(#team)]) end
The first one will put the first player in the first team, then the second player in the second team, and so on.
If, when you get to the last i, the teams are uneven, the same thing happens, thus making the teams even.
If, when you get to the last i, the teams are already even, the last player is put in a random team. |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2014 04:56 PM |
| @ROBOFROG I understand what you are saying, but I am not quite sure how to do that. |
|
|
| Report Abuse |
|
|
tyzone
|
  |
| Joined: 16 Aug 2008 |
| Total Posts: 1726 |
|
|
| 27 Aug 2014 04:59 PM |
Following ROBOFROG's method, you'd have to create a variable for each team.
blu = 0 red = 0
If blu == red, pick a random number between 1 and 2. If it's one, switch the player to the first team, and increase blu by one. Otherwise, if it's two, switch the player to the second team, and increase red by one.
If blu < red, switch the player to the first team. Increase blu by one.
If blu > red, switch the player to the second team. Increase red by one. |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2014 05:02 PM |
@Tyzone so would it be:
while true do wait(1) for i,v in pairs(Game.Players:GetPlayers()) do team = {"Bright yellow", "Dark stone grey"} if i ~= #game.Players:GetPlayers() or #game.Players:GetPlayers()%#team ~= 0 then v.TeamColor = BrickColor.new(team[(i%#team+)1]) else v.TeamColor = BrickColor.new(team[math.random(#team)]) end end wait(3) for i,v in pairs(Game.Players:GetPlayers()) do v.TeamColor = BrickColor.new("White")
end
end
To be honest I have no idea what this would do lol, but on line 6 there is an error |
|
|
| Report Abuse |
|
|
tyzone
|
  |
| Joined: 16 Aug 2008 |
| Total Posts: 1726 |
|
|
| 27 Aug 2014 05:06 PM |
I put the parenthesis in the wrong place. Sorry about that.
v.TeamColor = BrickColor.new(team[(i%#team)+1])
If i is an even number, it will return 1. If i is an odd number, it will return 2. |
|
|
| Report Abuse |
|
|