How to get all Datastores of Experience

Hello,
i was wondering how do you get all datastores inside a experience? Including the ones in another place (but still inside the experience)
~ Maini

game:GetService("DataStoreService"):ListDataStoresAsync()

But when I do:

print(game:GetService("DataStoreService"):ListDataStoresAsync())

There is coming this:
grafik

Yes, because a data store is an instance.

DataStoreService:ListDataStoresAsync() returns a DataStoreListingPages instance, so you will need to treat the instance as you would with a normal Pages instance.

1 Like

But I want to get the Name of the datastore

then you use DataStoreService:ListDataStoresAsync, get the Data from the Page, and print the Names by iterating over it (if i remember correctly, they are put into tables under a Page?)

Sorry, but I’m kinda new to lua coding, so could you write this code for me please?

I will not spoonfeed you the code, but I will provide you the proper documentation. There is example code on this page:

When i want to print it there is coming this:
function: 0xb0ffd7b4812f3340

Check the Output Settings, you may have Log Mode Enabled, Disable it.

1 Like

I don’t have Log Mode enabled
~ maini

@DasKairo is probably correct, you have log mode on, go to the three dots at the right corner of the output and make log mode disabled

image

What are you trying to print specifically?

I want to print the names of all the datastores in the experience.

I know that is your end goal, but what are you running in the command bar?

local dss = game:GetService("DataStoreService")

function iterPageItems(pages)
	return coroutine.wrap(function()
		local pagenum = 1
		while true do
			for _, item in ipairs(pages:GetCurrentPage()) do
				coroutine.yield(item, pagenum)
			end
			if pages.IsFinished then
				break
			end
			pages:AdvanceToNextPageAsync()
			pagenum = pagenum + 1
		end
	end)
end

game.Players.PlayerAdded:Connect(function(plr)

	

		
	local DatastoreService = game:GetService("DataStoreService"):GetGlobalDataStore()
	
	
	print(iterPageItems(game:GetService("DataStoreService"):ListDataStoresAsync()))

		local Datastore = DatastoreService
		local Key = plr.UserId .."_Saves"
		local Data = Datastore:GetAsync(Key)
		if Data then
			for i, v in ipairs(Data) do
				if plr.savestats:FindFirstChild(v[1]) then
					plr.savestats:FindFirstChild(v[1]).Value = v[2]
				end
			end
		end
		


		game.Players.PlayerRemoving:Connect(function(plr)
			local Key = plr.UserId .."_Saves"
			local data = {}
			for i, v in ipairs(plr.savestats:GetChildren()) do
				if v.Name ~= "Hunger" then
					table.insert(data, {v.Name, v.Value})
				end
			end

			Datastore:UpdateAsync(Key, function(pastData)
				return data
			end)

		end)
		

end)

The example code from the documentation does not fit your use case, but you should try to understand what each function of a Pages instance does and apply it to your use case.

Re-check please, you’re probably wrong, and send screenshot of settings please

I just dont understand the documentation