Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I use team:GetPlayers on specific team?

I have got this here, but It only works for every team in the game. Is there a way to change to one team only?

wait(3) local teams = game:GetService("Teams"):GetTeams() for _, team in pairs(teams) do local players = team:GetPlayers() -- specific team players instead of just the word team print("Team " .. team.Name .. " has " .. #players .. " players")

end

1 answer

✓ Accepted answer

Instead of attempting to use that function you can make a function that will check wether the players are in or not in the certain team.

local players = game:GetService("Players")

local tab = players:GetChildren() -- creates a table with all the players online
local number = 0  --sets a variable

for i = 1, #tab do

if tab[i].Team == game.Teams.TheTeamName then -- put the team location inside of the game
	
number = number+1 --summs up when the player belongs to the team
end	
	
end

print(number) -- this will give you the amount of players on the team

Remember to upvote my answer, and feel free to make any sort of questions :D

1 comment

0

thank you very much prooheckcp. That was very helpfull

This discussion is preserved as it was. New answers, comments, and votes are closed.