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

Why is this counter script not working?

Asked by 10 years ago

What this script is supposed to do is to detect how many people are on a team and to update a value to the number of people on that team. The script doesn't work, and I don't know why, as output didn't give me anything relating to the script. Can someone please help me? Here's the script:

while true do
    local plrs = game.Players:getPlayers()
    local allies = script.Parent.Yellows
    local enemies = script.Parent.Blues
    local guests = script.Parent.Reds
    if #plrs >= 1 then
        for i = 1, #plrs do
            if plrs[i].TeamColor == game.Teams["Blue"].TeamColor then
                enemies.Value = enemies.Value + 1
            elseif plrs[i].TeamColor == game.Teams["Yellow"].TeamColor then
                allies.Value = allies.Value + 1
            elseif plrs[i].TeamColor == game.Teams["Red"].TeamColor then
                guests.Value = guests.Value + 1
            end
        end
    end
end 

Answer this question