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

How can I make this script count the players on one specific team, instead of all the teams?

Asked by 5 years ago

How can I make this count the players on one specific team, instead of all the teams?

local Display = script.Parent
local teams = game:GetService("Teams"):GetTeams()
for _, team in pairs(teams) do
    local players = team:GetPlayers()
    Display.Text = ""..#players
end
1
i'm assuming this is not your script, the script writer should know User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by
cailir 284 Moderation Voter
5 years ago

Hello, ConnorThomp!

You can just check (if()) if the team color is equals to the team that you want. Here is the code:

local Display = script.Parent
local teams = game:GetService("Teams"):GetTeams()
for _, team in pairs(teams) do
    if(team.TeamColor == BrickColor.new("Change me to the team color!")) then
        local players = team:GetPlayers()
        Display.Text = ""..#players
    end
end

Good luck with your game!

0
why do you copy Leamir User#19524 175 — 5y
0
probably Leamir's alt acc hellmatic 1523 — 5y
1
I'm not Leamir's alt, i'm Leamir's brother cailir 284 — 5y
0
Yup, cailir is my brother Leamir 3138 — 5y
0
parenthesis are not necessary, but okay DeceptiveCaster 3761 — 5y
Ad

Answer this question