Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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
0
Stop capitalising every letter. radiant_Light203 1166 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

It would be easier to do

if #players == 0 then

then converting the number of players into a variable.

Ad

Answer this question