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

Cash for kill with datastore?

Asked by 3 years ago
Edited 3 years ago

Hi. I made a combat game, and i want to save the money a player makes every time he kills. I have tried some scripts, and i made some but none of them work. I hope you can help me

heres the cash for kill script:

game.Players.PlayerAdded:connect(function(player)

    local leaderstats = Instance.new("Folder",player)
    leaderstats.Name = "leaderstats"

    local cash = Instance.new("IntValue",leaderstats)
    cash.Name = "Pejecoins"
    cash.Value = 0

    local kills = Instance.new("IntValue",leaderstats)
    kills.Name = "Weyes Torcidos"
    kills.Value = 0


    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()

            local CreatorTag = character.Humanoid:FindFirstChild("creator")

            if CreatorTag and CreatorTag.Value then

                local stats = CreatorTag.Value:WaitForChild("leaderstats")

                stats["Pejecoins"].Value = stats["Pejecoins"].Value + 150
                stats["Weyes Torcidos"].Value = stats["Weyes Torcidos"].Value + 1        
                end
            end)
end)
end)

EDIT: Nvm, i found how to

Answer this question