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

I have problems with cash to kill + SaveData Script. Can anyone help or send me a better version? [closed]

Asked by 4 years ago
Edited by Ziffixture 4 years ago
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)
0
Can you put the entire thing in a code block so it is easier to understand? Txeer 46 — 4y

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?