I made a script that, when you kill a dummy you get cash. The leaderstats works perfectly but no cash is being added.
Kill for cash script:
local humanoid = script.Parent.Humanoid
function Dead()
local tag = humanoid:FindFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local stats = tag.Value:FindFirstChild("leaderstats")
if stats ~= nil then
stats.Kills.Value = stats.Cash.Value + 1
wait(0.1)
script:Remove()
end
end
end
end
humanoid.Died:Connect(Dead())
Leaderstats script:
local cashstore = game:GetService("DataStoreService"):GetDataStore("CashStore")
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder", player)
stats.Name = "leaderstats"
local kills = Instance.new("IntValue", stats)
kills.Name = "Kills"
kills.Value = 0
local cash = Instance.new("IntValue", stats)
cash.Name = "Cash"
local val = cashstore:GetAsync(player.UserId)
if val then
cash.Value = val
else
cash.Value = 0
end
end)
