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

GetTeams

The GetTeam function returns a table containing the game’s Team objects.

Note this will only return Team objects that are directly parented to the Teams service. For this reason it is recommended developers only parent Team objects to the Teams service and not to other Instances (or to each other).

Returns

Return Type Summary

An array of Teams in the game.


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