Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i convert to UpdateAsync from SetAsync on a datastore?

Here's the code i have been using.

game.Players.PlayerRemoving:Connect(function(player)
    local Key = "Coins".."-"..player.UserId
    pcall(function()
        DataStore:SetAsync(Key,player.leaderstats.Coins.Value) 
    end)
    print("DataStoreLog: Data Saving for "..player.Name)
end)

1 answer

✓ Accepted answer
DataStore:UpdateAsync(Key, function(CurrentState) 
	return Coins.Value or CurrentState 
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.