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 » Scripting Helpers
Home Search
 

Re: Rebalancing teams

Previous Thread :: Next Thread 
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 12:22 PM
How would I implement the math.random into my team rebalance so that it doesn't always put the players on the exact same team they were on previously?
Basically once the script is connected, it's sorts the players (apart from lavender team players) into the Red and Blue teams.
When I want to connect the function again, it puts the players in exactly the same coloured teams? I've been struggling with this for the past 2 days now, not sure what to do! Would really appreciate help?

Here is the code:

function randomiseteam()
for i, v in pairs( Game.Players:GetChildren( ) ) do
if v.TeamColor ~= BrickColor.new("Lavender") then
if i % 2 == 0 then
v.TeamColor = BrickColor.new( "Bright red" )
else
v.TeamColor = BrickColor.new( "Bright blue" )
end
v:LoadCharacter()
end
end
end

Would really appreciate some help please!
Report Abuse
Hippalectryon is not online. Hippalectryon
Joined: 17 Mar 2013
Total Posts: 45
06 Jun 2013 12:25 PM
http://wiki.roblox.com/index.php/RebalanceTeams_(Method)
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 12:29 PM
Erm, haha? So how would I implement that method into my script?
Report Abuse
Hippalectryon is not online. Hippalectryon
Joined: 17 Mar 2013
Total Posts: 45
06 Jun 2013 12:31 PM
i think it's game.Teams.THETEAMHERE:themethod()
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 12:34 PM
What does it mean by "this method does not appear to work as expected"
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 01:51 PM
Any help? D:
Report Abuse
Hippalectryon is not online. Hippalectryon
Joined: 17 Mar 2013
Total Posts: 45
06 Jun 2013 01:54 PM
You mean on the wiki? ignore it
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 02:26 PM
I just need some help sorting out my script so it doesn't continually put players on the same team each time it connects? People suggested a math.random so it randomly chooses some players and puts them on other team etc but I don't get it?
Report Abuse
Hippalectryon is not online. Hippalectryon
Joined: 17 Mar 2013
Total Posts: 45
06 Jun 2013 02:34 PM
Make a list with all the players, scramble the order of it's members, and TADAM appy your script to it
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
06 Jun 2013 02:45 PM
function scrambleTeams()
redTeam = {}
blueTeam = {}
teams = {redTeam,blueTeam}

players = game.Players:getChildren()

while wait() do
for key, value in pairs(teams)
wait()
rand = math.random(1,#players)
table.insert(value, players[rand])
table.remove(players, players[rand])
if #players == 0 then
return
end
end

end

That may not be right (i'm kinda derping) but something like that ;)
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 02:59 PM
Ah thank you!!! I'll try this soon :D
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 03:02 PM
Within the redTeam, should I do
game.Teams.Red? or?
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
06 Jun 2013 03:05 PM
Yeah reference your actual teams.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 03:05 PM
Alright thanks, I'll do that now.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 03:06 PM
Also you forgot a "do" on that for line :p
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
06 Jun 2013 03:07 PM
Told you i was derping lawl.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 03:36 PM
It says, bad argument
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
06 Jun 2013 03:38 PM
where?
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 03:42 PM
bad argument error #2 to 'remove'
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 03:43 PM
That is what it says on the remote error monitoring.

Line 100:

table.remove(players, players[rand])
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
06 Jun 2013 03:46 PM
oops.

table.remove(players, rand)
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 03:48 PM
Alright, I'll test this!
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 03:53 PM
I tested it, and there was no error displayed in the remote error, BUT, nothing happened, me and my tester didn't get sorted into a team.
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
06 Jun 2013 04:02 PM
Put this at the end.


for key, value in pairs(redTeam) do
value.TeamColor = BrickColor.new("Bright red")
end

for key, value in pairs(blueTeam)do
value.TeamColor = BrickColor.new("Bright blue")
end
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
06 Jun 2013 04:10 PM
Done, but another error.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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