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: How do I make this team scrambler scramble 4 teams?

Previous Thread :: Next Thread 
CrimsonForce is not online. CrimsonForce
Joined: 11 Sep 2010
Total Posts: 35714
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 is not online. 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
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
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
CrimsonForce is not online. CrimsonForce
Joined: 11 Sep 2010
Total Posts: 35714
25 Jun 2015 11:58 AM
lord that worked, thank you
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
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
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