So, I was using SetAsync everytime to update my data however this lead to some troubles as it didn't register later on, so I was wondering is it OK to do the following and, is it efficient or, is there a better way to go around it?
Before:
DataStoreName:SetAsync(user, tablefullofvalues)
--This would happen every-time the user made a purchase, however it seems to glitch a lot and overwrite the previous data as nil or, false whichever, except for the key that the user just purchased.
After:
Note: This is just an idea, wondering if it's efficient, or should I go about it a different way? I don't really want to use the PlayerRemoving Event because if the server crashes they lose their data because they never "left," or is that solved by using game.OnClose.. etc?
DataStoreName:UpdateAsync(user, function(oldvalue)
local newValue = tablefullofvalues
return newValue
end)
--Then,
function AutoSave()
DataStoreName:SetAsync(user, tablefullofvalues)
delay(200, function()
AutoSave()
end)
end
Is After better or, is there yet a more efficent way of doing it besides this and PlayerRemoving or, can you prevent data loss from crashes by using game.OnClose?

2 comments
After is definitely better. However, ditch SetAsync completely.
So, just save using game.OnClose and PlayerRemoving?