coreOrderedDatastore v1 | GetOrderedPositionAsync



The system I’ve produced represents an implementation of an OrderedDatastore. This system allows you to retrieve a Specific key & update a set of Key-Value pairs.

Configurables, Functions & Params

	-- Variables
	local isDescending = true -- SortingOrder / Ascending or Descending
	local convertUserIdToString = true -- Auto convert UserId to string, else pass it as a string manually
	local isUsingPromisedUpdate = true -- Using the Built-In UpdateAsync that came with the module
	local OrderedDatastoreName = "MyTestingVersion" -- Name of your OrderedDatastore

	-- Functions & Params
	Retrieves the entry & position of a specified key within an ordered data store.
	coreOrderedDatastore:GetOrderedPositionAsync(Key: string | number, Descending: boolean)

	@param Key (string | number): The key to search for within the ordered data store. It can be either a string or a number varying on the convertUserIdToString boolean.
	@param Descending (boolean): Determines the ascending order when searching for the key. Set to true to search in descending order or false for ascending order.
    Asynchronously updates data for a Player in the Datastore
	coreOrderedDatastore:UpdateAsync(Player: Player, Key: string, Value: number)

	@param Player (Player): The player whose key you want to update.
	@param Key (string): The key associated with the player's data. Should be a string.
	@param Value (number): The new numeric value to update for the player. string, ConvertUserIdToString: boolean)
	Returns a new OrderedDatastore object
	@param OrderedDatastoreName (string): The name of the provided Ordered Datastore
	@param ConvertUserIdToString (boolean): Indicates whether user IDs should be converted to strings when interacting with the data store.
	@constructor string, ConvertUserIdToString: boolean)


  1. Grab the Model Found Here
  2. Drag the contents into ServerScriptService
  3. Setup the configurable variables inside of coreStore to your likings
  4. Run & Success!

Suggestions & Feedback

If this is in high need, I may maintain the system. If that’s the case, feel free to list features you guys would like to see :slight_smile:


Ah, most importantly I forgot to return the entry, however I was returning the position. It returns the following data:

    [1] = {
        ["key"] = "2731068564", -- userId: string
        ["value"] = 10 -- value for the users key: number
    [2] = 27 -- position in queue: number

Edit: Reversed the returning order, mainly hence original request was for the position, however it varies on the page as well.

    [1] = 27 -- position in queue: number,
    [2] = {
        ["key"] = "2731068564", -- userId: string
        ["value"] = 10 -- value for the users key: number
1 Like