UpdateAsync only saves ordered data and not regular data

I switched my whole game’s DataStore system a while ago to a more easy to manage and stable system that relies on UpdateAsync and tables.

I also switched my OrderedData to the new system.

Recently, my normal DataStore data doesn’t save after the player leaves, however it returns success, evidenced by the print statements.

However, the ordered data saves and updates normally.

Can anyone help me on this?

Regular data save code:

local function savePlayerData(player)
	if sessionData[player] then
		return dataStoreRetry(function()
			local success = pcall(function()
				playerData:UpdateAsync(dataKey .. player.UserId, function()
					return sessionData[player]
				end)				
			end)	
			
			if success then
				print("Saved data for " .. player.Name)
			end
		end)
	end
end

Ordered data save code:

local function orderData()
	for _, player in pairs(Players:GetPlayers()) do
		return dataStoreRetry(function()
			local success = pcall(function()
				playerOrderedData:UpdateAsync(orderedKey .. player.UserId, function()
					return sessionData[player].TotalExperience
				end)			
			end)
		end)	
	end
end

Ensure that the datastore keys are the same in the :GetAsync and the :SetAsync. You’d be surprised how often they are slightly different!

Also, using UpdateAsync provides no benefit over SetAsync if you aren’t doing processing between the old and the new data to ensure that the new data makes sense. the function() part of the UpdateAsync thing has a parameter in the () which is the old data.

The DataStore keys are the same, they’re stored in a variable. I tried SetAsync too, but it doesn’t work either…

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