Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Money Per Kill Script Gives the Killed Player Money?

Asked by 2 months ago

Hi, this script is supposed to give the player who killed another player money, however the player who died is the one who gets it. Any reason why this is?

game.Players.PlayerAdded:connect(function(player)
    local folder = Instance.new("Folder",player)
    folder.Name = "leaderstats"
    local currency1 = Instance.new("IntValue",folder)
    currency1.Name = "Gold"

    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            local tag = character.Humanoid:FindFirstChild("creator")
            if tag ~= nil then
                if tag.Value ~= nil then
                    character.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 10
                end
            end
        end)
    end)
end)

1 answer

Log in to vote
1
Answered by
blockmask 351 Moderation Voter
2 months ago

1)Don't use free scripts 2)Why are you checking in character for the leaderstats? 3)You're supposed to be using the tag's value to find the player. 4)Indent


local reward = 0.001 --lol game.Players.PlayerAdded:connect(function(player) local folder = Instance.new("Folder") folder.Name = "leaderstats" folder.Parent = player local currency1 = Instance.new("IntValue") currency1.Name = "Gold" currency1.Parent = player player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() local tag = character.Humanoid:FindFirstChild("creator") if tag ~= nil then if game.Players:FindFirstChild(tag.Value) then game.Players[tag.Value].leaderstats.Gold = game.Players[tag.Value].leaderstats.Gold + reward end end end) end) end)
0
Nevermind, ignore #4 blockmask 351 — 2mo
Ad

Answer this question