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

Is there anyway to check if there is no children of an object?

Asked by
Seenit 80
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I need to check if there is no players on a team but I cant find a method to do so.

0
Players are not children of their team; your title is irrelevant to your question BlueTaslem 18071 — 10y

1 answer

Log in to vote
0
Answered by
acecateer 130
10 years ago

Try this:

function getPlayerNumberInTeam(TeamColor)
    local num = 0
    for index,player in pairs(game.Players:GetChildren()) do
        if player.TeamColor == TeamColor and not player.Neutral then
            num = num+1
        end
    end
return num
end

print(getPlayerNumberInTeam(game.Teams.Team.TeamColor))
0
1) Tab your code 2) `BrickColor`s are directly comparable. There is no need to use `tostring`. BlueTaslem 18071 — 10y
0
Typed it in notepad. :P acecateer 130 — 10y
0
Notepad has tabs. So does the editor on this site. BlueTaslem 18071 — 10y
0
Yeah, sorry. I just decided not to use tabs. I'll fix it. acecateer 130 — 10y
Ad

Answer this question