Team Score not updating when player died

My team score updating module is not working, and I cannot seem to find why it will not update the scores.

My code is this:

local module = {}

function module.HandleDeath(plr)
    local TS = game.ReplicatedStorage:WaitForChild("TeamScore")
    
    if plr.TeamColor == BrickColor.new("bright red") then
        TS.BlueScore.Value = TS.BlueScore.Value + 1
    elseif plr.TeamColor == BrickColor.new("Bright blue") then
        TS.RedScore.Value = TS.RedScore.Value + 1
    else
        return nil
    end
end

function module:Start()
    local teamScore = game.ReplicatedStorage:WaitForChild("TeamScore")

    for _,v in pairs(teamScore:GetChildren()) do
        v.Value = 0
        
        if teamScore.RedScore.Value == 0 and teamScore.BlueScore.Value == 0 then 
            break 
        else
            return
        end
    end
end

return module

If anyone knows why this doesn’t work, please let me know!

2 Likes

i think that’s because you’re using TeamColor and sometimes people having issues with TeamColor. Try using if plr.Team == game.Teams.TEAMNAME then

2 Likes

I’ll try that, if it doesn’t work I will let you know

1 Like