pages = AdHistoryKeys:GetSortedAsync(false, 100)
pagesTable = {}
pcall(function()
while wait() do
local currentTable = {}
print("1: "..#pages:GetCurrentPage())
for _,v in pairs(pages:GetCurrentPage()) do
local value = AdHistory:GetAsync(v.key) -- problem here
table.insert(currentTable,#currentTable+1,value)
end
table.insert(pagesTable, currentTable)
pages:AdvanceToNextPageAsync()
end
end)
for _,page in pairs(pagesTable) do
print(#page)
for _,v in pairs(page) do
print("2: "..v) -- prints only one value from the current page
end
end
First: AdHistoryKeys is a OrderedDataStore with a key for AdHistory (a regular DataStore), and the value being a timestamp, so I can sort by the last created.
my problem lies in AdHistory:GetAsync(v.key)
I found that if I replace that with a normal table, it will work fine. I've figured out that it's because of datastore limits. How I was planning on fixing this was just having a single key with a dictionary for the value, but I'm not sure if that's the best way. My only fear would be it could easily corrupt all data inside the table.

2 comments
https://scriptinghelpers.org/questions/16401/how-would-i-use-getsortedasync-to-make-a-leaderboard
That's not what I'm trying to do, I have to store the keys of a regular dataStore inside of an orderedDataStore. The problem is that I can't get all the values of the dataStore as it limits the amount of GetAsync calls you can make.