game.Players.PlayerAdded:connect(function(player)
local GUI = game.StarterGui.GUI.TextLabel
GUI.Visible = false
local folder = Instance.new(“Folder”,player)
folder.Name = “leaderstats”
local currency1 = Instance.new(“IntValue”,folder)
currency1.Name = “Cash” --Your currency name here
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 + 100
GUI.Visible = true
wait(1)
GUI.Visible = false
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)