I am trying to make a function to get all of the keys from a global datastore
It keeps returning an empty table
I have been trying to ask the AI assistant and looked at forums, but couldn’t figure out what the issue was
function GetKeys(datastore)
local ds = game:GetService("DataStoreService"):GetDataStore(datastore)
local keys = {}
local pages = ds:ListKeysAsync()
while wait() do
for i, v in pairs(pages:GetCurrentPage()) do
table.insert(keys, v.KeyName)
end
if pages.IsFinished then
break
else
pages:AdvanceToNextPageAsync()
end
end
return keys
end
well, for testing purposes the datastore name was “yoink” and I would’ve realized it was wrong, and I added in total 20 keys each with a name going from well, 1 to 20 and each have a string of random letters. I have tried loading them with their keys and it worked, so neither of these are the issue
have tried, it doesn’t loop through the for loop and it doesn’t print in the pages:AdvanceToNextPage thingy, only the break. Also where would I add the pcall?