GetCurrentPage is not a valid member of OrderedDataStore

I was recently scripting a global leaderboard when I came across this error:
GetCurrentPage is not a valid member of OrderedDataStore

I asked my friends and they said they have never even seen this Pcall error nor even used GetCurrentPage()

local ds = game:GetService(“DataStoreService”)
local donorlb = ds:GetOrderedDataStore(“RadRacing1”)
local success, errormsg = pcall(function()
local data = donorlb
local donorpage = data:GetCurrentPage()
for rank, data in ipairs(donorpage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = userName
local wins = data.Value
local isOnLeadboard = false
for a,b in pairs(game.Players:GetChildren()) do
for i,v in pairs(b.PlayerGui.MainPage.leaderboard.donor:GetChildren()) do
if v.ClassName == “Frame” then
if v.name.Text == Name then
isOnLeadboard = true
break
end
end
end
end
if wins and isOnLeadboard == false then
for a,b in pairs(game.Players:GetChildren()) do
local newLbFrame = b.PlayerGui.MainPage.leaderboard.don:Clone()
newLbFrame.name.Text = Name
newLbFrame.amount.Text = wins
newLbFrame.rank.Text = “#”…rank
newLbFrame.Parent = b.PlayerGui.MainPage.leaderboard.donor
print(“Done”)
end
end
end
end)

Why did you create 2 variables for the same thing? you defined donorlb and then also put it under data.

Makes it easier and shorter.
But that isn’t my problem here and I am just trying to fix the issue.

I think you need to get sorted Async first before. Youre calling for a current page but you havent gotten it yet.

The error tells you that GetCurrentPage is not a function of OrderedDataStore - it is a function of the DataStorePages instance returned by GetSortedAsync, so you need to use GetSortedAsync:

local donorpages = donorlb:GetSortedAsync(false, 10)
local donorpage = donorpages:GetCurrentPage()

The second argument of GetSortedAsync is supposed to be the number of entries that will be displayed. The function also has more arguments: refer to the GetSortedAsync page

2 Likes

Yes. Much better way of explaining it.