generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Simple team randomize

Previous Thread :: Next Thread 
Lasoor is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Lasoor
Joined: 17 Jan 2016
Total Posts: 5596
17 Feb 2016 05:31 PM
lold


Report Abuse
Casualist is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image