I have this and if a new player leaves the new game would the updateasync set the new value to Coins.Value since their is no prior value?
local leaderstats = Player.leaderstats
local Coins = leaderstats.Coins
local Success, Response = pcall(function()
CoinDataStore:UpdateAsync(key, function(oldValue)
local newValue = oldValue or Coins.Value
return newValue
end)
end)
If the saved data is equal to nil, then save using :SetAsync. If it is not, safe using :UpdateAsync. At least that’s what I understand from this thread.
The link I sent is the most detailed. It explains everything to why SetAsync is bad for updating data and the other features UpdateAsync has other than the oldValue.