I have problems with cash to kill + SaveData Script. Can anyone help or send me a better version? [closed]
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)
Closed as Not Constructive by Ziffixture
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?