How do I get all the data in a datastore?

I’m trying to use OrderedDatastores but this code doesn’t seem to be printing anything?
I made sure to actually create the “PlayerData” datastore aswell

local PlayerDataStore = DatastoreService:GetOrderedDataStore("PlayerData")

local results = PlayerDataStore:GetSortedAsync(false, 100)

while true do
	
	local currentPage = results:GetCurrentPage()

	for _, entry in ipairs(currentPage) do
		local key =  entry.key
		local value = entry.value
		
		print(key, value)
	end
	
	if results.IsFinished then
		break
	end
	
	results:AdvanceToNextPageAsync()
	
end

With some foraging I found the solution

local PlayerStore = DatastoreService:GetDataStore("PlayerData")

local success, pages = pcall(function()
	return PlayerStore:ListKeysAsync()
end)

if success then
	while task.wait() do
		local items = pages:GetCurrentPage()
		
		for _, Data in ipairs(items) do
			print(Data.KeyName)
		end
		
		if pages.IsFinished then break
		
		else
			pages:AdvanceToNextPageAsync()
		end
		
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.