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

How To Get The Amount Of Players On A Certain Team Not On All Teams?

Since My last Idea Isn't Working To Find When Someone Dies On A Team, I made so when someone dies They Change Team, So I Have to Detect The Amount Of Player On a team Reach 0, Something Triggers. But I Don't Know How To Do It

Here Is The Script I Have But The Only Problem is That It gets the amount on ALL Teams Not Just The one I want

wait(20)
local teams = game:GetService("Teams"):GetTeams("Leader")
for _, team in pairs(teams) do
    local players = team:GetPlayers()
    print("Team " .. team.Name .. " has " .. #players .. " players")
	local Players = #players
	local LO = game.Workspace.Palace.LeaderSign.Folder
	print(Players)
	if Players == 0 then
				script.Parent.LeaderTeamChanger.Disabled = false
				print("Leader Died")
				script.Parent.PlaceHolder.Value = script.Parent.Leader.Value
				script.Parent.Leader.Value = LO.NL1.Value
				LO.NL2.Value = LO.NL3.Value
				LO.NL3.Value = LO.NL4.Value
				LO.NL4.Value = LO.NL5.Value
				LO.NL5.Value = LO.NL6.Value
				LO.NL6.Value = LO.NL7.Value
				LO.NL7.Value = LO.NL8.Value
				LO.NL8.Value = LO.NL9.Value
				LO.NL9.Value = LO.NL10.Value
				LO.NL10.Value = script.Parent.PlaceHolder.Value
				script.Parent.PlaceHolder.Value = "Blank"				
				script.Parent.LeaderTeamChanger.Disabled = true
	
	end
end

1 comment

0

Stop capitalising every letter.

1 answer

It would be easier to do

if #players == 0 then

then converting the number of players into a variable.

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