Issue with DatasStore:ListKeysAsync()

I want my code to retrieve all the data that has been saved from each player that joins, without having to retrieve individually each piece of data. I’m using :ListKeysAsync() to retrieve all the keys that hold data from the player in question and then with those keys use :GetAsync().

The problem is that I find this method unreliavable as there are some keys that are not retrieved, but are correctly saved in the datastore (checked with the plugin “DataStoreEditor” in studio).

The only solution I can think of is adding the keys manually for the data I want to retrieve and call :GetAsync() with each one, but the whole point of using :ListKeysAsync() was to avoid having to manually write the keys ¡n the script.

This is my code:

local function get(Player,Slot,Key)
	if typeof(Key) == "table" then
		local data = {}

		for i,v in pairs(Key)do
			data[i] = Slot and dataToSave[Player][Slot][v] or dataToSave[Player][v] or defaultValues[v]
		end
		
		return data
	else
		local Slot = tonumber(Slot)
		return Slot and dataToSave[Player][Slot][Key] or dataToSave[Player][Key] or defaultValues[Key]
	end
end

ReplicatedStorage.Remotes.Data.fromClient.Get.OnServerInvoke = (function(Player:Player,Slot,Key:string)
	if not Key then

		local success,msg = nil,nil
		local playerData = {{},{},{}}
		local attempts = 0

		repeat 

			success,msg = pcall(function()
				local data:DataStoreKeyPages = Global:ListKeysAsync(Player.UserId.."/",0,nil,true)
				while not data.IsFinished do
					local page = data:GetCurrentPage()
					for i, v in page do
						local key = page[i].KeyName
						local split = key:split("/") print(i,key)
						if #split > 2 then
							playerData[tonumber(split[2])][split[3]] = Global:GetAsync(key)
						else
							local value = Global:GetAsync(key)
							playerData[key] = value
						end
					end
					data:AdvanceToNextPageAsync()
					task.wait()
				end
			end)
			attempts += 1

			if not success then warn(msg) task.wait(3) end

		until success or attempts == 5

		if success then
			dataToSave[Player] = playerData
		else
			Player:Kick("Unable to load your data. Please try again later.")
		end

	elseif Key == "LobbyData" then
		local data = {}
		data.BoughtSpins = dataToSave[Player].BoughtSpins or 0
		for i = 1,3 do
			data[i] = {
				Spins = dataToSave[Player][i].Spins,
				Bloodline = dataToSave[Player][i].Bloodline,
				Level = dataToSave[Player][i].Level,
				Species = dataToSave[Player][i].Species,
			}	
		end

		return data
	else
		get(Player,Slot,Key)
	end
end)
ReplicatedStorage.Remotes.Data.fromClient.Delete.OnServerInvoke = function(Player,Slot)
	if dataToSave[Player] and dataToSave[Player][Slot] then
		dataToSave[Player][Slot] = {}
	end
end

ReplicatedStorage.Remotes.Data.fromServer.Set.Event:Connect(function(Player,Slot,Key,Value)
	if typeof(Key) == "table" then
		for Key,Value in pairs(Key)do
			dataToSave[Player][Slot][Key] = Value
		end
	else
		if Slot then
			dataToSave[Player][Slot][Key] = Value
		else
			dataToSave[Player][Key] = Value
		end
	end
end)
ReplicatedStorage.Remotes.Data.fromServer.Increment.Event:Connect(function(Player,Slot,Key,Increment)
	if Slot then
		dataToSave[Player][Slot][Key] = get(Player,Slot,Key) + Increment
	else
		dataToSave[Player][Key] = get(Player,Slot,Key) + Increment
	end
end)
ReplicatedStorage.Remotes.Data.fromServer.Get.OnInvoke = get

local function save(Player)
	if dataToSave[Player] then
		local ID = Player.UserId
		print(dataToSave[Player])
		local success, msg = pcall(function()
			for key,value in pairs(dataToSave[Player]) do
				local slot = key
				if typeof(value) == "table" then
					for key,v in pairs(dataToSave[Player][slot])do
						Global:SetAsync(ID.."/"..slot.."/"..key,v)
					end
				else
					Global:SetAsync(ID.."/"..key,value)
				end
			end
		end)
		if not success then warn(msg) end

		dataToSave[Player] = nil
	end
end
Players.PlayerAdded:Connect(function(Player)
end)
Players.PlayerRemoving:Connect(function(Player)
	save(Player)
end)
game:BindToClose(function()
	for i,Player in pairs(Players:GetPlayers())do
		task.spawn(function()
			save(Player)
		end)
	end
end)