Struggling with OrderedDatastore

Hello, I’m struggling with OrderedDataStore, I’m trying to make a leaderboard, but only {} is printed:

local DataStoreService = game:GetService("DataStoreService")
local ObbyCompletions = DataStoreService:GetOrderedDataStore("ObbyCompStore")

local function updateLeaderboard()
	local success, error = pcall(function()
		local Data = ObbyCompletions:GetSortedAsync(false, 10)
		local DataPage = Data:GetCurrentPage()
		print(DataPage)
	end)
end

print(updateLeaderboard())

However, the following code correctly increments and prints the stat, so why is OrderedDataStore not working properly?

local dataStore = DataStoreService:GetDataStore("ObbyCompStore")
local currentCompletions = dataStore:GetAsync(player.UserId .. "completions") or 0
			dataStore:SetAsync(player.UserId .. "completions", currentCompletions + 1)
			
			local completions = dataStore:GetAsync(player.UserId .. "completions")
			print("Current completions: " .. completions)

Because you’re accessing different datastores in both scripts. In the first one an OrderedDataStore but in the second one a regular DataStore.

1 Like

That worked, thank you! I thought that OrderedDataStore was only a way to display data in a normal datastore.

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