Lasoor
|
  |
| Joined: 17 Jan 2016 |
| Total Posts: 5596 |
|
|
| 17 Feb 2016 04:47 PM |
I don't know why so many people do math and crap to randomize players into two teams. I see everyone using complex stuff, many lines of code, etc...
Here's all I do...
local players = game.Players:GetChildren() local bool = true for i=1,#players do if bool == true then players[i].TeamColor = BrickColor.new("Bright red") elseif bool == false then players[i].TeamColor = BrickColor.new("Bright blue") end end
|
|
|
| Report Abuse |
|
|
Lasoor
|
  |
| Joined: 17 Jan 2016 |
| Total Posts: 5596 |
|
|
| 17 Feb 2016 04:48 PM |
crap forgot something lol
Here's what I actually do:
local players = game.Players:GetChildren() local bool = true for i=1,#players do if bool == true then players[i].TeamColor = BrickColor.new("Bright red") bool = false elseif bool == false then players[i].TeamColor = BrickColor.new("Bright blue") bool = true end end
|
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 17 Feb 2016 05:07 PM |
Even simpler:
for a,player in pairs(game.Players:GetPlayers()) do if a%2 == 0 then players[i].TeamColor = BrickColor.new("Bright red") else players[i].TeamColor = BrickColor.new("Bright blue") end end
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 17 Feb 2016 05:08 PM |
Oops, typos.
for a,player in pairs(game.Players:GetPlayers()) do if a%2 == 0 then player.TeamColor = BrickColor.new("Bright red") else player.TeamColor = BrickColor.new("Bright blue") end end
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
Lasoor
|
  |
| Joined: 17 Jan 2016 |
| Total Posts: 5596 |
|
|
| 17 Feb 2016 05:21 PM |
"Even simpler:"
May be less typing, but to me that's more complicated lol More confusing to read that.
|
|
|
| Report Abuse |
|
|
iiEssence
|
  |
| Joined: 18 Jun 2014 |
| Total Posts: 3467 |
|
|
| 17 Feb 2016 05:23 PM |
It's not complicated. I'm assuming you never seen '%' before.
Basically, it returns the remainder after diving the first number by the second. |
|
|
| Report Abuse |
|
|
Lasoor
|
  |
| Joined: 17 Jan 2016 |
| Total Posts: 5596 |
|
|
| 17 Feb 2016 05:25 PM |
I'm not a noob. I read it just fine, but it required more thinking to read because it is less "english" than my scripting preference. I script things in a way where a noob should be able to understand it since to me that makes most sense anyway.
|
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
|
| 17 Feb 2016 05:27 PM |
LOL, when i first read your thread, my first thought of a team randomizer would be to use Math.random() and other math complex stuff,
then I saw your post and I was like, this is so simple. xDDDD
also, 'cr**' is a bad word!!! dont say it!!! |
|
|
| Report Abuse |
|
|
Lasoor
|
  |
| Joined: 17 Jan 2016 |
| Total Posts: 5596 |
|
| |
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 17 Feb 2016 07:41 PM |
So by your line of thought, this should refresh the teams once per second and the players should be randomized
while wait(1) do local players = game.Players:GetPlayers() local bool = true for i=1,#players do if bool == true then players[i].TeamColor = BrickColor.new("Bright red") elseif bool == false then players[i].TeamColor = BrickColor.new("Bright blue") end bool = not bool end end
Open up a test server with 4+ players. Look at how not random it is. The order in which players join determines which team you get placed on. |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 17 Feb 2016 07:55 PM |
No, it's Alphabetical order according to there names.
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 17 Feb 2016 07:58 PM |
| No, it's by who joins first. There is no way they changed it to do that lmao |
|
|
| Report Abuse |
|
|