|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 02 Mar 2014 07:47 PM |
@maxo Didnt really work out that well. Anyone else? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 02 Mar 2014 09:42 PM |
game.Workspace.NumberValue.Value = playersOnTeam("Zombies")
... |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 03 Mar 2014 07:08 PM |
| Iterate through players, and teams, check their TeamColor against THE TeamColor |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 06 Mar 2014 05:01 PM |
| Everyone on the "Bright red" team will be inserted into the table! |
|
|
| Report Abuse |
|
|