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

I have a problem with my leaderboard? [Unanswered]

Asked by
Relatch 550 Moderation Voter
9 years ago

In this script, it creates the leaderboard, but doesn't award kills or gold. Help? No errors either.

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local money = Instance.new("IntValue")
    money.Name = "Money"
    money.Value = 0
    money.Parent = leaderstats

    local kills = Instance.new("IntValue")
    kills.Name = "Kills"
    kills.Value = 0
    kills.Parent = leaderstats

    local level = Instance.new("IntValue")
    level.Name = "Level"
    level.Value = 1
    level.Parent = leaderstats

    game.Players.PlayerAdded:connect(function(player)
        player.CharacterAdded:connect(function(character)
            character.Humanoid.Died:connect(function()
                local killer = character.Humanoid:findFirstChild("creator")
                if killer then
                    killer.leaderstats.Kills.Value = killer.Value.Kills.Value + 1
                    killer.leaderstats.Money.Value = killer.leaderstats.Money.Value + 3
                end
            end)
        end)
    end)
end)
0
I don't have time to read through that thoroughly, but NEVER EVER EVER use two identical events in the same script! It's scary, and 100% pointless! Just use a SINGLE PlayerAdded event for everything you want done. Perci1 4988 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

I think the problem has to be in the third function. Try this:

 game.Players.PlayerAdded:connect(function(player)
        player.CharacterAdded:connect(function(character)
            character.Humanoid.Died:connect(function(chr) -- I gave this function a parameter
                local killer = chr.Humanoid:findFirstChild("creator") -- switched character to chr
                if killer then
                    killer.leaderstats.Kills.Value = killer.Value.Kills.Value + 1
                    killer.leaderstats.Money.Value = killer.leaderstats.Money.Value + 3

Hope this helps.

0
didn't work. Relatch 550 — 9y
Ad

Answer this question