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

How To Find The Amount Of Players On A Team?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
-1
Answered by 4 years ago

i think this is help u

01local Players = game.Players:GetPlayers() -- This Line Get a list of players
02 
03local Team = game.Teams.Prisoner -- Put your team in here
04 
05local InTeam = {} -- This is the list of Players is on Team Prisoner
06 
07for _, Player in pairs(Players) do
08    if Player.Team == Team then
09        table.insert(InTeam, Player)
10    end
11end
12 
13print(#InTeam)
0
WHY U DONT CHECK UR QUESTION? Ariya1234gamer 15 — 4y
0
WHY U DONT CHECK UR QUESTION? Ariya1234gamer 15 — 4y
0
It was 1 HOUR AGO, maybe they haven't checked it yet. BashGuy10 384 — 4y
0
You also do not need to use tables, :GetPlayers() returns a table, so you can do #players to get the amount of players BashGuy10 384 — 4y
0
but we dont want amount of players it make the code longer Ariya1234gamer 15 — 4y
Ad
Log in to vote
0
Answered by
BashGuy10 384 Moderation Voter
4 years ago

A simple solution to this is simply:

1local players = game.Players:GetPlayers()
2 
3print(#players) -- prints the number of players

Answer this question