local function getTeamDistribution()
local teams = {}
for _, player in pairs(game:GetService('Players'):GetPlayers()) do
local teamName = tostring(player.Team)
if not teams[teamName] then
teams[teamName] = 0
end
teams[teamName] += 1
end
return teams
end
-- only use the above function for work; everything below is just a usage example
local function usageExample()
for teamName, teamCount in pairs(getTeamDistribution()) do
print(teamName .. ' has ' .. teamCount .. ' players.')
end
end
while wait(1) do
usageExample()
end