local success, errorMessage = pcall(function()
MainDataStore:UpdateAsync(player.UserId,function(oldValue)
local previousData = oldValue or {DataId = 0}
if player.DataId.Value == previousData.DataId then
data.DataId += 1
warn("Saved data 1")
return data
else
if previousData.DataId == nil then
data.DataId += 1
warn("Saved data 2")
return data
else
warn("Saved no data 1")
return nil
end
end
end)
end)
When people rejoin my game sometimes, they don’t get their newer data, but instead get their older data
Edit: does this work too?
local success, errorMessage = pcall(function()
MainDataStore:UpdateAsync(player.UserId,function()
data.DataId += 1
return data
end)
end)
You’d have to use SetAsync then. UpdateAsync on a table is pretty much doing the same thing as SetAsync with a table. DataStore does not account for tables when using UpdateAsync.
SetAsync causes data loss. Tons of posts say that. If you owned a game with more than 200 players you’d know. One day the data loss strikes and it feels like the end of the world