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

How can I check to see if certain teams have no players on them?

I want to check to see if certain teams have no players and if they don't have any players, then make the console print something. Any help?

1 answer

✓ Accepted answer

teams have a :GetPlayers() function which returns a list of players on that team. You can get the length of any list by putting a # before it.

local team = game.Teams.TEAM_NAME_HERE

local players = team:GetPlayers()
local number_of_players = #players
if number_of_players == 0 then
	print("team has no players!")
end

3 comments

1

Tried running it and it doesn't print anything.

0

Oh sorry, I messed up on line 5. Should be if number_of_players == 0

0

Oh thanks.

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