game.Players.PlayerAdded:connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Cash" ----- Name of currency
cash.Value = 0
cash.Parent = folder
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
local tag = character.Humanoid:FindFirstChild("creator")
if tag ~= nil then
local player = tag.Value
local bounty = 20
local leaderstats = player:WaitForChild("leaderstats")
leaderstats.Cash.Value = leaderstats.Cash.Value + bounty
end
end)
end)
end)
local ID = currencyName.."-"..player.UserId
local savedData = nil
pcall(function()
savedData = DataStore:GetAsync(ID)
end)
if savedData ~= nil then
currency.Value = savedData
print("Data loaded")
else
-- New player
currency.Value = 50
print("New player to the game")
end
end) -And here it tells me "Expected eof, got end" What should I do?
game.Players.PlayerRemoving:Connect(function(player)
local ID = currencyName.."-"..player.UserId
DataStore:SetAsync(ID,player.leaderstats[currencyName].Value)
end)
game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
if player then
player:Kick("This game is shutting down")
end
end
wait(5)
end)
COMMUNITY QUESTION
I have problems with cash to kill + SaveData Script. Can anyone help or send me a better version?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Can you put the entire thing in a code block so it is easier to understand?