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 could i randomly assign a player to a team (2 teams)

Previous Thread :: Next Thread 
ninjaguy77777 is not online. ninjaguy77777
Joined: 15 Oct 2011
Total Posts: 2382
23 Apr 2017 01:13 PM
also the team has to be balanced


shadilay
Report Abuse
HaydenSpernato is not online. HaydenSpernato
Joined: 06 Dec 2012
Total Posts: 2004
23 Apr 2017 01:14 PM
PlayerAdded

math.random
Report Abuse
graveyardposse is not online. graveyardposse
Joined: 23 Oct 2008
Total Posts: 2565
23 Apr 2017 01:19 PM
teamcolors = {'Really red','Really black'}

for _,v in pairs(game.Players:GetPlayers()) do
v.TeamColor = teamcolors[math.random(1,#teamcolors)]
end
Report Abuse
graveyardposse is not online. graveyardposse
Joined: 23 Oct 2008
Total Posts: 2565
23 Apr 2017 01:20 PM
im not sure if you change teamcolors w brickcolor btw so if that's the case just put BrickColor.new() around it
Report Abuse
LordDracius is online. LordDracius
Joined: 22 Oct 2011
Total Posts: 1056
23 Apr 2017 01:24 PM
Those scripts above aren't balanced...

local teams=game:GetService('Teams')
local red=teams:WaitForChild('Red')
local blue=teams:WaitForChild('Blue')

local list={blue,red}

game:GetService('Players').PlayerAdded:connect(function(player)

if #red:GetPlayers()>#blue:GetPlayers()then
player.TeamColor=blue.TeamColor
elseif #red:GetPlayers()<#blue:GetPlayers()then
player.TeamColor=red.TeamColor
else
player.TeamColor=list[math.random(1,#list)]
end

end)
Report Abuse
graveyardposse is not online. graveyardposse
Joined: 23 Oct 2008
Total Posts: 2565
23 Apr 2017 02:46 PM
didn't realize he said balanced mb
Report Abuse
ninjaguy77777 is not online. ninjaguy77777
Joined: 15 Oct 2011
Total Posts: 2382
23 Apr 2017 10:03 PM
im making a minigames script and for some reason its not working


local rt = Instance.new("Team",game.Teams)
local bt = Instance.new("Team",game.Teams)
rt.Name = "Red"
rt.TeamColor = BrickColor.new("Really red")
bt.Name = "Blue"
bt.TeamColor = BrickColor.new("Really blue")
wait()
local teams=game:GetService('Teams')
local red=teams:WaitForChild('Red')
local blue=teams:WaitForChild('Blue')

local list={blue,red}

for i,player in pairs (game.Players:GetChildren()) do
if #red:GetPlayers()>#blue:GetPlayers()then
player.TeamColor=blue.TeamColor
elseif #red:GetPlayers()<#blue:GetPlayers()then
player.TeamColor=red.TeamColor
else
player.TeamColor=list[math.random(1,#list)]
end
end


shadilay
Report Abuse
Dratik is online. Dratik
Joined: 13 Nov 2008
Total Posts: 36385
23 Apr 2017 10:16 PM
output?


Report Abuse
ninjaguy77777 is not online. ninjaguy77777
Joined: 15 Oct 2011
Total Posts: 2382
23 Apr 2017 10:17 PM
something about getting a brickcolor and expecting an object i believe


shadilay
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
23 Apr 2017 10:24 PM
local function randomizeTeams(...)
local players, teams = game.Players:GetPlayers(), {...}
for x = 1, (#players), 1 do
local y = math.random(1, (#players))
players[x], players[y] = players[y], players[x]
end
for x = 1, (#players), 1 do
players[x].TeamColor = BrickColor.new(teams[(x % (#teams)) + 1])
end
return (nil);
end

randomizeTeams("Bright blue", "Bright red", "Bright green")
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
23 Apr 2017 10:30 PM
only one person was capable enough to use modulus and make it easy


Report Abuse
ninjaguy77777 is not online. ninjaguy77777
Joined: 15 Oct 2011
Total Posts: 2382
24 Apr 2017 03:11 PM
its not assigning me to a team, im just neutral


shadilay
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
24 Apr 2017 05:43 PM
Mine? I don't see how, but I can't test it right now when I tested first I did it with 8 players
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