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

Why Wont this work?

Asked by 10 years ago

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

i am a Near-Amature scripter so i dont anderstand alot of things. SO f you could help me fix this it would help alot! THANks! CODE:

d = game:GetService("Teams")
if d.Players == 0 then -- Meaning if there is no players in the team

****Again, I am a amature, so i dont understand it, Sorry if this is a request :/

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

It's always best to look stuff up before you use it in your code. As it turns out, the property you are trying to use simply does not exist. To actually get the number of players on a team, it's much more complicated.

We must loop through all the Players and check their TeamColor property, then use a variable to keep track of how many players had that same TeamColor.

local blueNum = 0
for index, player in pairs(game.Players:GetPlayers()) do
    if player.TeamColor == BrickColor.new("Bright blue") then
        blueNum = blueNum + 1
    end
end
print(blueNum)
0
Thanks!, but how do i make it so it will run if there's no players on said team? ioutragous 0 — 10y
0
It WILL run if there's no players on the said team. There is nothing to prevent this code from running. I think I'm misunderstanding...? Perci1 4988 — 10y
Ad

Answer this question