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

can u use like if game.players.numplayers == 0 then but for teams?

what im asking is can u do like if there is 0 players on a team then

2 answers

Firstly Roblox has deprecated NumPlayers so we now have to get the list of players using GetPlayers then getting the length of the table.

E.g.

print(#game:GetService('Players'):GetPlayers()) -- print the number of players

Roblox has also added a function to get the list of players the team has GetPlayers we can then use the same method shown above to get the number of players in that team.

Hope this helps.

3 comments

0

^ You beat me to it

0

this isn't even what he asked -.- read the title.......

0

@F4ULT1NTH3D4T4 I have provided all of the information needed needed to resolve the question.

I don't know a way to get the number of players in a team with a built-in roblox function or property but here is one I made, returns the amount of players in the team name you provided

function PlrsInTeam(teamname)
	local plrs = {}
	for i,v in pairs(game.Players:GetPlayers()) do
		if v.Team == game:GetService("Teams")[teamname] then
			table.insert(plrs,v)
		end
	end
	return #plrs
end

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