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

How To Find The Amount Of Players On A Team?

I Am Really Close On Finishing A Game And I Don't Know How To Find The Amount Of Players On A Team

I need Some Help

2 answers

✓ Accepted answer

i think this is help u

local Players = game.Players:GetPlayers() -- This Line Get a list of players

local Team = game.Teams.Prisoner -- Put your team in here

local InTeam = {} -- This is the list of Players is on Team Prisoner

for _, Player in pairs(Players) do
	if Player.Team == Team then
		table.insert(InTeam, Player)
	end
end

print(#InTeam)

5 comments

0

WHY U DONT CHECK UR QUESTION?

0

WHY U DONT CHECK UR QUESTION?

0

It was 1 HOUR AGO, maybe they haven't checked it yet.

0

You also do not need to use tables, :GetPlayers() returns a table, so you can do #players to get the amount of players

0

but we dont want amount of players it make the code longer

A simple solution to this is simply:

local players = game.Players:GetPlayers()

print(#players) -- prints the number of players

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