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: Help!!!

Previous Thread :: Next Thread 
Skenderbeu98 is not online. Skenderbeu98
Joined: 11 Aug 2013
Total Posts: 467
02 Mar 2014 02:37 PM
How do I get the the number of people on one team?
I am making a new zombie place sort of like left4dead but different, and I need to track the number of people under both teams so I know when to end the round.
Report Abuse
KingJacko is not online. KingJacko
Joined: 20 Jun 2008
Total Posts: 3944
02 Mar 2014 02:39 PM
you are going to have to go through each player and see what team they are on. I would do this with the player entered function(i dont know the function off the top of my head)
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
02 Mar 2014 02:41 PM
Oh my, this puzzled me for a long time. I have something Bebee wrote up that seems to work well.

_G["PLAYER_CHECK"] = function (color)
local PLAYER_COUNT = 0
for _,v in pairs(game.Players:GetPlayers()) do
if v.TeamColor.Name == color.Name then
PLAYER_COUNT = PLAYER_COUNT + 1
end
end
return PLAYER_COUNT
end


print (_G.PLAYER_CHECK (BrickColor.new 'Really blue'))
Report Abuse
Skenderbeu98 is not online. Skenderbeu98
Joined: 11 Aug 2013
Total Posts: 467
02 Mar 2014 07:47 PM
@maxo
Didnt really work out that well.
Anyone else?
Report Abuse
Eternalfireeater is not online. Eternalfireeater
Joined: 01 May 2011
Total Posts: 10027
02 Mar 2014 07:51 PM
function playerOnTeam(teamname)
players = {}
teamcolor = game:GetService("Teams")[teamname].TeamColor

for _,v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == teamcolor then
table.insert(players, v)
end
end
return #players
end
Report Abuse
Eternalfireeater is not online. Eternalfireeater
Joined: 01 May 2011
Total Posts: 10027
02 Mar 2014 07:52 PM
function playersOnTeam(teamname)
players = {}
teamcolor = game:GetService("Teams")[teamname].TeamColor

for _,v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == teamcolor then
table.insert(players, v)
end
end
return #players
end
Report Abuse
Skenderbeu98 is not online. Skenderbeu98
Joined: 11 Aug 2013
Total Posts: 467
02 Mar 2014 08:55 PM
How do I utilize that code you posted on my #players on a team thread to change the value of a NumberValue to the number of players on a team?
Report Abuse
Eternalfireeater is not online. Eternalfireeater
Joined: 01 May 2011
Total Posts: 10027
02 Mar 2014 09:42 PM
game.Workspace.NumberValue.Value = playersOnTeam("Zombies")

...
Report Abuse
Skenderbeu98 is not online. Skenderbeu98
Joined: 11 Aug 2013
Total Posts: 467
03 Mar 2014 06:50 PM
19:49:40.880 - Workspace.Script:2: attempt to call global 'playersOnTeam' (a nil value)
I also tried 'PlayersOnTeam', same thing.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Mar 2014 07:08 PM
Iterate through players, and teams, check their TeamColor against THE TeamColor
Report Abuse
Skenderbeu98 is not online. Skenderbeu98
Joined: 11 Aug 2013
Total Posts: 467
06 Mar 2014 02:54 PM
@warspy
How do I do that?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Mar 2014 05:00 PM
Something like

Players = game.Players:GetPlayers()
red = "Bright red"
Numberred = {}

for I = 1, #Players do
col = Players[I].TeamColor
if col = red then
table.insert(Numberred, Players[I])
end
end

--Try that?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Mar 2014 05:01 PM
Everyone on the "Bright red" team will be inserted into the table!
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