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 3 years ago
Edited 3 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 3 years ago

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)

0
WHY U DONT CHECK UR QUESTION? Ariya1234gamer 15 — 3y
0
WHY U DONT CHECK UR QUESTION? Ariya1234gamer 15 — 3y
0
It was 1 HOUR AGO, maybe they haven't checked it yet. BashGuy10 384 — 3y
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 — 3y
0
but we dont want amount of players it make the code longer Ariya1234gamer 15 — 3y
Ad
Log in to vote
0
Answered by
BashGuy10 384 Moderation Voter
3 years ago

A simple solution to this is simply:

local players = game.Players:GetPlayers()

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

Answer this question