I want to get all the keys from DataStore to later use them to obtain certain data. I chose to use ListKeysAsync(), but I get an error on the fifth DataStore page.
For some reason, I only get the error in-game, in studio, it works well. Also, the error appeared today (February 17th), without having made any updates to the datastore.
I tried implementing a cooldown but I still get the same error.
P.S.: The module is executed every 100 seconds.
The code:
local DATA_KEY = require(script.Parent.Key)
local Ranked = {}
--//> Services
local DataStoreService = game:GetService("DataStoreService")
--//> Variables
local options = Instance.new("DataStoreOptions")
options.AllScopes = true
local DataStore = DataStoreService:GetDataStore(DATA_KEY, "", options) :: DataStore
--//> Self Functions
function Ranked:get(tol: number)
local success, pages = pcall(function()
return DataStore:ListKeysAsync()
end)
if not success then return end
local now = os.time()
local tab = {}
while true do
local items = pages:GetCurrentPage()
for i, v in ipairs(items) do
local userkey = v.KeyName
local userdata = DataStore:GetAsync(userkey)
-- Data Manipulation --
local wins = {0, 0}
local kills = {0, 0}
local country = nil
if userdata then
country = userdata.country
wins[1] = #userdata.wins
for _, t in userdata.wins do
if (now - t <= tol) then
wins[2] += 1
end end
kills[1] = #userdata.kills
for _, t in userdata.kills do
if (now - t <= tol) then
kills[2] += 1
end end end
table.insert(tab, {tonumber(string.split(v.KeyName, "/")[2]), {wins = wins, kills = kills}, country})
-----------------------
end
if pages.IsFinished then break end
pages:AdvanceToNextPageAsync()
end
return tab
end
return Ranked
The error:
Thank you ![]()
