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)