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

Need help on this cash on every kill script?

Asked by 3 years ago

Ok so I want this so that it gives you 20 cash every time when you kill a humanoid. I want to do this without making a new leaderstat because I already have cash. Every time when someone kills, it doesn't give cash. Any help?

0
Can you provide the script that you attempted to use? Omq_ItzJasmin 666 — 3y
0
I did its on the answer CalarqnicKen 8 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

game.Players.PlayerAdded:connect(function(player) currency1.Name = "Cash" player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() local tag = character.Humanoid:FindFirstChild("creator") if tag ~= nil then local killer = tag.Value if killer ~= nil then -- Find the killer's leaderstats folder local killerStats = killer:FindFirstChild("leaderstats")

    if killerStats ~= nil then
        -- Find the killer's Cash IntValue
        local killerCash = killerStats:FindFirstChild("Cash")

        -- Increase cash as before
        killerCash.Value = killerCash.Value + 10
    end

end end end) end) end) local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local Cash = Instance.new("IntValue",leader) Cash.Name = "Cash" Cash.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, Cash.Value) Cash.Changed:connect(function() ds:SetAsync(player.UserId, Cash.Value) end) end)

game.Players.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) end)

0
Its not working can u help me? CalarqnicKen 8 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

uh dis script dat giv cash. I no put datastor. idk if work tho hehe

game.Players.PlayerAdded:Connect(function(player) 
    local currency1 = Instance.new('IntValue', player)
    currency1.Name = "Cash" 
    player.CharacterAdded:Connect(function(character)
        local Humanoid = character:WaitForChild'Humanoid'
        Humanoid.Died:Connect(function() 
            local tag = Humanoid:FindFirstChild("creator") 
            if tag ~= nil then 
                local killer = tag.Value 
                killer.leaderstats.Cash.Value += 10
            end
        end)
    end)
end)

Answer this question