Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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 comment

1

i'm assuming this is not your script, the script writer should know

1 answer

✓ Accepted answer

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!

5 comments

0

why do you copy Leamir

0

probably Leamir's alt acc

1

I'm not Leamir's alt, i'm Leamir's brother

0

Yup, cailir is my brother

0

parenthesis are not necessary, but okay

This discussion is preserved as it was. New answers, comments, and votes are closed.