i have a datastore, lets call it DataStore001.
i have some saved keys in it and i want to get them all with :ListKeysAsync()
if i print it it prints only “Instance”
if i use :GetAsync it prints the name of the Key.
is there a way, that ListKeysAsync() prints the key name?
It’s printing “Instance” because the :ListKeysAsync() method returns a DataStoreVersionPages Instance not a table. You’ll need to do this to read the data inside your DataStore correctly:
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore001") -- Change this to match the name you want to use
local success, pages = pcall(DataStore.ListKeysAsync, DataStore)
if success then
while true do
local items = pages:GetCurrentPage()
for index, dataStoreKey in items do
local success, value = pcall(DataStore.GetAsync, DataStore, dataStoreKey.KeyName)
if success then print(value) end
end
if pages.IsFinished then break end
pages:AdvanceToNextPageAsync()
end
end