Player data saves when one of these happens:
- They leave the game
- BindToClose
- AutoSave (every 5 minutes)
Currently the game saves the player data once, it doesn’t attempt to save it several tries until it’s either failed or is success. It just saves it in the pcall.
pcall(function()
CashStore:SetAsync(player.UserId, Cash.Value)
end)
Should I have attempts?
local tries = 0
local success
repeat
tries = tries + 1
print("saving data: "..player.Name.."-"..player.UserId)
success = pcall(function()
CashStore:SetAsync(player.UserId, Cash.Value)
end)
if not success then wait(1) end
until tries == 10 or success
if not success then
warn("Cannot save data for player!: "..player.Name.."-"..player.UserId)
--pfolder:Destroy()
else
print("Data has been saved successfully!: "..player.Name.."-"..player.UserId)
--pfolder:Destroy()
end
Is it advisable? If so, how many attempts should it be?