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

Problem with my leaderboard?

This script is supposed to give the player to killed another player 3 money, and 1 kill. But when I kill someone else, it doesn't work. It also don't get any errors. Help?

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)

4 comments

0

Is the tag actually in the humanoid? You need to do this using a script.

0

This isn't even what i'm asking for.

0

Is the creator in the humanoid? If not then you need to go into the link.

1 answer

You're using the PlayerAdded event twice. The second one isn't loading. Additionally, this should be in a severscript if it isn't already.

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

        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)

5 comments

0

What's the "creator" inside of the humanoid?

0

You can have multiple of the same events inside of each other, It's just not really needed.

0

Still isn't working.

0

It would help if I knew what the "creator" inside of humanoid was. That seems to be your problem. And using PlayerAdded twice means it will create a huge mess of irrelevant code for every player that enters.

0

Your problem might be having CharacterAdded so close to the bottom of the code. It might not be running the first time the character is loaded.

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