Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't these values increase on death?

Coudn't seem to find out what was wrong with this one. The only error it gives me is " Attempt to connect failed: Passed value is not a function", but im not sure that error refers to this script. Would anyone happen to know just how to fix this script? Thanks! ;)

local RedTeamDeaths = game.Workspace.Config.RedDeaths

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        Humanoid.Died:connect(function(Died)
			if Player.TeamColor == BrickColor.Red() then
                RedTeamDeaths.Value = RedTeamDeaths.Value + 1
            end
        end)
    end)
end)

2 answers

✓ Accepted answer

Remove Died inside of the parentheses on line 6. The Died event doesn't pass any arguments.

"Red()" isn't a function. Try to remove the () at the end of it, so the code could be like

local RedTeamDeaths = game.Workspace.Config.RedDeaths

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        Humanoid.Died:connect(function(Died)
            if Player.TeamColor == BrickColor.Red then
                RedTeamDeaths.Value = RedTeamDeaths.Value + 1
            end
        end)
    end)
end)

If you're using something like "'Bright red" then you would have to do something like

local RedTeamDeaths = game.Workspace.Config.RedDeaths

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        Humanoid.Died:connect(function(Died)
            if Player.TeamColor == BrickColor["Bright red"] then
                RedTeamDeaths.Value = RedTeamDeaths.Value + 1
            end
        end)
    end)
end)

I haven't tried this code out, so if it doesn't work tell me and I can fix it.

1 comment

This discussion is preserved as it was. New answers, comments, and votes are closed.