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

Why won't these values increase on death?

Asked by 7 years ago
Edited 7 years ago

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

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
7 years ago

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

Ad
Log in to vote
-1
Answered by 7 years ago

"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.

Answer this question