PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetPlayers

Returns a list of Players who are assigned to the Team. A Player is considered assigned if their Player/Team property is equal to the Team and Player/Neutral is false.

This function has a number of potential uses, including counting the number of players on a Team or giving every Player on a Team a Tool.

Returns

Return Type Summary

An array of Players in the Team.


Code Samples


Teams GetTeams

The example below prints the number of players on each Team.

-- count how many players are on each team
local teams = game:GetService("Teams"):GetTeams()
for _, team in pairs(teams) do
    local players = team:GetPlayers()
    print("Team " .. team.Name .. " has " .. #players .. " players")
end