How do I detect how many people are on a specific team?

I’ve been curious about this for a lil bit, and I am quite curious on how I would do it. (Mainly for round systems). So, please let me know how I would do it.

1 Like

have tried it yourself?
ideas:

  • loop trough all players and get their team, count them accordingly
  • (idk if it exists but) check if there is a function on the team folder that allows for this?

and next time please give more details than just 2 sentences. (some people might report you for it)

Using :GetPlayers() method on a Team returns an array of Players. Use the “#” operator next to the array to get the array’s size

local teamPlayers = game.Teams.Team:GetPlayers()
local playerAmount = #teamPlayers

UPD: pretty clear example from the source I noted above

local Teams = game:GetService("Teams")

local teams = Teams:GetTeams()

for _, team in pairs(teams) do
	local players = team:GetPlayers()
	print("Team", team.Name, "has", #players, "players")
end
2 Likes