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: Randomised team change

Previous Thread :: Next Thread 
MuneebParwazMP is not online. MuneebParwazMP
Joined: 27 May 2014
Total Posts: 233
15 May 2016 10:59 AM
In studio I have 3 teams:
-Lobby
-Red
-Blue

Everyone is in the lobby team. I need a script to make every player go into either red or blue team. The red and blue team has to have an equal amount of players!


Report Abuse
Salinas23 is not online. Salinas23
Joined: 28 Dec 2008
Total Posts: 37142
15 May 2016 11:03 AM
1) find how many players are in the server
2) pick one random player, and make its team red
3) repeat until half of the server players are in team read
4) blue team will consist of those left in lobby
Report Abuse
MuneebParwazMP is not online. MuneebParwazMP
Joined: 27 May 2014
Total Posts: 233
15 May 2016 11:09 AM
May I have a script please?


Report Abuse
KLGA is not online. KLGA
Joined: 19 Apr 2014
Total Posts: 2571
15 May 2016 11:15 AM
local teams = {"Bright red","Bright blue","Black"} --change these to colors of team
for i,v in pairs(game.Players:GetPlayers()) do
v.TeamColor = teams[(i%3)+1]
end
Report Abuse
KLGA is not online. KLGA
Joined: 19 Apr 2014
Total Posts: 2571
15 May 2016 11:16 AM
didn't read post lol remove lobby color from table and change the second number in the modulus equation to 2
Report Abuse
MuneebParwazMP is not online. MuneebParwazMP
Joined: 27 May 2014
Total Posts: 233
15 May 2016 11:17 AM
Thanks


Report Abuse
MuneebParwazMP is not online. MuneebParwazMP
Joined: 27 May 2014
Total Posts: 233
15 May 2016 11:27 AM
Nvm, that didn't work for some reason.


Report Abuse
MuneebParwazMP is not online. MuneebParwazMP
Joined: 27 May 2014
Total Posts: 233
15 May 2016 11:27 AM
Is it correct?
local teams = {"Bright red","Bright blue"}
for i,v in pairs(game.Players:GetPlayers()) do
v.TeamColor = teams[(i%2)+1]
end


Report Abuse
KLGA is not online. KLGA
Joined: 19 Apr 2014
Total Posts: 2571
15 May 2016 11:31 AM
Yep, make sure the two colors in the table are the EXACT same as the two teamcolors (same caps, spelling, spaces, etc)
Report Abuse
MuneebParwazMP is not online. MuneebParwazMP
Joined: 27 May 2014
Total Posts: 233
15 May 2016 11:32 AM
I did


Report Abuse
MuneebParwazMP is not online. MuneebParwazMP
Joined: 27 May 2014
Total Posts: 233
15 May 2016 11:33 AM
Should I used BrickColor.new?


Report Abuse
KLGA is not online. KLGA
Joined: 19 Apr 2014
Total Posts: 2571
15 May 2016 11:33 AM
oh, duh, you need to put the table values as brickcolor values not string values, my bad
Report Abuse
MuneebParwazMP is not online. MuneebParwazMP
Joined: 27 May 2014
Total Posts: 233
15 May 2016 11:35 AM
So how should I do it?
local teams = ???
for i,v in pairs(game.Players:GetPlayers()) do
v.TeamColor= ???
end


Report Abuse
KLGA is not online. KLGA
Joined: 19 Apr 2014
Total Posts: 2571
15 May 2016 11:36 AM
leave line 4 as it is,

change the table values

local teams = {BrickColor.new("Bright red"),BrickColor.new("Bright blue")}
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