Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to check the amount of players on a team?

Asked by 9 years ago
for _,v in pairs(game.Players:GetPlayers()) do
    if v.TeamColor == BrickColor.new("Bright blue") then
        blueteam.Value = blueteam.Value + 1
    elseif v.TeamColor == BrickColor.new("Bright red") then
        redteam.Value = redteam.Value + 1
    end
end

I am trying to make it so it checks the amount of players on a team, so it would say print 5, being 5 people are on red team.

0
This is correct, assuming redteam and blueteam are defined. Make sure you remember to reset the values between tests, though. Perci1 4988 — 9y
0
yeah it works, but when there is 2 players, it says 1 for blue value and 2 for red, even though theres only 1 for each team? NinjoOnline 1146 — 9y
0
how can I get it to just count the players so if theres 8 people it says 4 blue 4 red NinjoOnline 1146 — 9y

1 answer

Log in to vote
1
Answered by
RedCombee 585 Moderation Voter
9 years ago

You can check all the players and find their team color, essentially letting you see how many players are on a team.

teamtable1 = {}
for i,v in pairs(game.Players:GetChildren()) do
    if v.TeamColor == BrickColor.new("Color Here") then -- Checks every player for their Team Color
        table.insert(teamtable1,v)
    end
end
0
ok so I just add print(teamtable1)??? NinjoOnline 1146 — 9y
0
i eddited my answer with what i have. It works, with one player, giving blue + 1 vlue, but when I try with 2 players it says blue = 1 and red = 2, why is this? NinjoOnline 1146 — 9y
Ad

Answer this question