How does :UpdateAsync() work?

I’ve recently been having trouble with the DataStoreService:UpdateAsync() function. I made a script where once you have enough cash and purchase an item from the store, the :UpdateAsync() function should update the amount of cash that a specific player has in their specific data. It works, however, once you leave and rejoin, the number of cash resets to what you had prior to purchasing.

I’ve tried looking online for tutorials but there is limited information about this topic, and quite frankly, the Roblox developer hub about UpdateAsync is very confusing to understand, especially for someone like me who is new to DataStoreService and scripting as a whole.

Save the money when the money gets changed or when the player leaves.
Here is a good post which explains :UpdateAsync(): How to Properly use UpdateAsync()

So either

Money:GetPropertyChangedSignal("Value"):Connect(function()
   ... -- save it here
end)
-- OR
game:GetService("Players").PlayerRemoving:Connect(function()
   ... -- save it here
end)
2 Likes

Script worked perfectly, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.