[Solved] Ordered data store not updating correctly

Hello!
I am making an admin panel for updating and removing people from an ordered data store leaderboard.

In the update and remove functions (Server-Sided) when I use RemoveAsync or UpdateAsync the datastore never updates to the new values. Unless I run the function over 500+ times, it worked once :confused:

I have looked around the devforum and found no topic pinpointing this problem.

Lè functions

-- retry(retries: number, callback: (...) -> any, ...): (any?, boolean)
-- retries running the callback *x* amount of times if an error is thrown.
-- *isWhitelisted* is just a utility function, don't mind it

function RemoveUserData(player, leaderBoard, targetPlayerId)
	if not isWhitelisted(player.UserId) then return end
	
	local _, success = retry(4, function(ds: OrderedDataStore)
		return ds:RemoveAsync(targetPlayerId)
	end, DataStore)
	
	if not success then
		print("WARN: There was an error removing user data.")
	end
end

function UpdateUserData(player, leaderBoard, targetPlayerId, newTime)
	if not isWhitelisted(player.UserId) then return end
	
	local _, success = retry(4, function(ds: OrderedDataStore)
		return ds:UpdateAsync(targetPlayerId, function()
			return tonumber(("%0.0f"):format(newTime * 1000))
		end)
	end, DataStore)
	
	if not success then
		print("WARN: There was an error trying to update a user.")
	end
end

Thanks!

  • SkyLord_103
2 Likes

Retrying a datastore save is unlikely to do much if the same data is used and it is done within a short time period.

If you attempt to remove them without using retry and instead just use pcall, does it have any better results? (You can catch errors using pcall, which can then be outputed and examined)

(Also, are you certain that it is getting past the isWhitelisted line?)

1 Like

I did find the problem with it. It was how to data was saved on the server then saved to the datastore.

Thanks for the reply tho!

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