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

Would this work for getting the amount of players in a team?

I don't really use teams that much so I'm no very good at coding with them. I want to make it so if someone tries to join a team, but it has 25 players in it, nothing will happen. But, since I don't really know how to get the amount of players in a team, I just kind of guessed.

local b = game.Teams.Cops:GetChildren()

if b == 25 then
print("nope")
end

Would code like that work, or are the amount of players on a team stored differently?

3 comments

0

Try 'if #b == 25 then'

0

Nope, that didn't work.

0

A table is never equivalent to a number.

1 answer

You want to use the GetPlayers() method when it comes to game.Players or a Team.

local b = game.Teams.Cops:GetPlayers() -- this method returns a table of all the players
if #b == 25 then -- the # operator gets the length of the table
	print("nope")
end

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