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

Problem with my leaderboard?

Asked by
Relatch 550 Moderation Voter
9 years ago

I made this leaderboard that sets it up, also rewarding 3 tokens and 1 kill. When I kill another player, that doesn't happen. Help?

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

    local tokens = Instance.new("IntValue")
    tokens.Name = "Tokens"
    tokens.Value = 0
    tokens.Parent = leaderstats

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

    player.CharacterAdded:connect(function(chr)
        local chr = player.Character
        chr.Humanoid.Died:connect(function(chr)
            local chr = player.Character
            local killer = chr.Humanoid:findFirstChild("creator")
            if killer then
                killer.leaderstats.Kills.Value = killer.Value.Kills.Value + 1
                killer.leaderstats.Tokens.Value = killer.leaderstats.Tokens.Value + 3
            end
        end)
    end)
end)

1 answer

Log in to vote
2
Answered by 9 years ago

the killer's player instance would be killer.Value so:

local plrwhokilled = killer.Value
plrwhokilled.leaderstats.Kills.Value = plrwhokilled.leaderstats.Kills.Value + 1
--and so on
Ad

Answer this question