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
 

Placing Players randomly into 1 of 2 teams instead...

Previous Thread :: Next Thread 
Revontheous is not online. Revontheous
Joined: 29 Jan 2009
Total Posts: 6337
30 Aug 2015 10:29 PM
Instead of placing it in just 1 team?

I have a blue team and a red team. I only know how to make it place a player into just the Blue Team. How do I make it also, randomly, place a player on one of the 2 teams instead of just 1?

script.Parent.MouseButton1Down:connect(function()
script.Parent.Parent.Parent.Frame.Visible = false
script.Parent.Parent.Parent.Announcer.Visible = true
wait(3)
script.Parent.Parent.Parent.Announcer.Visible = false
script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Navy blue")
script.Parent.Parent.Parent.Parent.Parent:LoadCharacter()

end)

Report Abuse
Revontheous is not online. Revontheous
Joined: 29 Jan 2009
Total Posts: 6337
31 Aug 2015 12:02 AM
Bump

http://www.roblox.com/Revontheous-Final-Form-item?id=289896594 If I didn't have any bad luck, I'd have no luck at all!
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
31 Aug 2015 12:11 AM
local teams = {"Navy blue", "Really red"} --Change 'Really red' to the other team's brick color

script.Parent.MouseButton1Down:connect(function()

local TeamChosen = teams[math.random(1,#teams)]

script.Parent.Parent.Parent.Frame.Visible = false
script.Parent.Parent.Parent.Announcer.Visible = true
wait(3)
script.Parent.Parent.Parent.Announcer.Visible = false
script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new(TeamChosen)
script.Parent.Parent.Parent.Parent.Parent:LoadCharacter()

end)




"When we say 'Computer,' we mean the Electronic Computer"
Report Abuse
Revontheous is not online. Revontheous
Joined: 29 Jan 2009
Total Posts: 6337
31 Aug 2015 04:01 AM
Unfortunately, that didn't work. It still spawned many players just on the Blue Team...

Also, is there a Team Balance in there as well?

Report Abuse
OldGoldie is not online. OldGoldie
Joined: 17 Aug 2010
Total Posts: 8210
31 Aug 2015 04:43 AM
All you need to do with teams is check the property, I forget what it is but its like StarterTeam or something. The team with the least players will get put on that team after they join.
Report Abuse
ImaginaryUnit is not online. ImaginaryUnit
Joined: 04 Jun 2014
Total Posts: 16
31 Aug 2015 05:13 AM
AutoAssignable :)
Report Abuse
Revontheous is not online. Revontheous
Joined: 29 Jan 2009
Total Posts: 6337
31 Aug 2015 12:39 PM
Well, actually, not autoassignable because 1, first there is a spawn team where all players who join, get sent to that team. Once the round begins, and the player presses 'Play', they get sent to one of the 2 teams... Red or Blue.

Yet, my script only is able to send players to the Blue team and not the Red.
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
31 Aug 2015 12:44 PM
if # blue >= # red then
player.team = red
else
player.team = blue
end
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
31 Aug 2015 12:53 PM
You could use modulus like

local players = game.Players:GetPlayers()
local teamcolors = {game.Teams.Red.TeamColor,game.Teams.Blue.TeamColor}
playersleft = #players
while playersleft > 0 do
val = playersleft%2 -- using modulus to decide if number is even or odd
if val = 0 then
players[1].TeamColor = teamcolors[1]
elseif val = 1 then
players[1].TeamColor = teamcolors[2]
end
playersleft = playersleft - 1
end

Idk if the above will work but here is a tutorial on modulus that may help by Arbitrayor5 :
http://www.roblox.com/Forum/ShowPost.aspx?PostID=45890315


Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
31 Aug 2015 12:55 PM
Sorry did a mistake :
local players = game.Players:GetPlayers()
local teamcolors = {game.Teams.Red.TeamColor,game.Teams.Blue.TeamColor}
playersleft = #players
while playersleft > 0 do
val = playersleft%2 -- using modulus to decide if number is even or odd
if val = 0 then
players[1].TeamColor = teamcolors[1]
elseif val = 1 then
players[1].TeamColor = teamcolors[2]
end
players[1] = nil
end
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
31 Aug 2015 01:00 PM
Yo just use mine its like not even hard
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