I’ve heard you shouldn’t use SetAsync to save data, instead, you should use UpdateAsync to do the job. But I’ve looked on YouTube and couldn’t find a tutorial that uses UpdateAsync, and Roblox’s API references don’t help either. How would I use UpdateAsync to save data?
Datastore:UpdateAsync(plr.UserId, function(oldVal)
local newValue = oldVal or 0 --In case there is no old value, set it to 0
newValue = newValue + 1 --Add 1 to whatever
return newValue
end)
That’s it. Just return a value from the transform function and that value will be saved. It’s just like SetAsync but with a function instead of data.
1 Like