Listing all existing DataStores in a game

Hello all,

I’m currently writing a hands-on, in-game DataStore explorer panel so that my development team can browse and read through various DataStores. Unfortunately, I haven’t been able to find a concrete way to actually return all existing DataStores in the form of a table. In explicit terms, I’m looking for a function that returns the name of every DataStore that I’ve created.

Best Regards.

1 Like

I’ve absolutely no idea of doing it but I do have some few stuff to share which “might” help.

Might be asking why plugins?

Using the Plugin Importer Plugin you can get the source code of the DataStore Editor v3 plugin.

Then try using the source code of the DataStore Editor v3 plugin and trying playing around with it, to get the DataStores inside of your game.

Again I did said I’ve no idea of how to do so. These are just what I think “might” be “useful”.

1 Like

Thank you for the recommendations. I’ll await any other suggestions and return to this reply as the Solution if nothing else comes along.

2 Likes

Not really an expert at DataStores but, do you want the DataStores to be displayed on GUI? Also I probably do think that you do need to do this manually.

Off-topic: Since class ended just now ima go to studio lol

2 Likes

Yes, the datastores will be displayed on the UI, which I do know how to set up. It’s only the matter of retrieving a list of the existing, separate datastores that I’m concerned about.

Edit: corrected typo

1 Like

I think every DataStore is located in DataStoreService. If you want to get key/value pairs however, I don’t think that’s possible.

This should get the names of every DataStore ingame:

local ds = game:GetService("DataStoreService"):GetChildren()
for x,v in pairs(ds) do
    print(v.Name)
end

Edit: Changed let to local, getting too comfortable with JavaScript :sweat_smile:

5 Likes

I don’t think it’s actually possible to just get a list of all of the datastores in your game, I do remember seeing a ListDataStoresAsync() function for DataStoreService on the wiki but it doesn’t seem to be working at the moment.

Assuming you want to access all the individual player datastores, what you can do is use a global datastore to keep a log of all the player UserIds that have ever joined the game, and then you can use that list to get all of the datastore keys for each player

That’s not how you get the datastores, that’s getting the children that are parented to the service instance.

If I remember correctly, it’s apart of the datastoreservice revamp v2 that’ll have this supported.

1 Like

I’ll give this a try when I’m out of work. Thank you all for the help!

1 Like

Oh yeah, true. They only come into existence once an action is performed on them when gotten with :GetDataStore(), I think

No, that’s not how datastores work…

Yeah, I’m probably wrong on a lot of things lol. I don’t experiment with DataStores much

The API reference is always your friend.

1 Like

Ah yes, I assume then this is the solution

Edit: This might be sort of useful!

1 Like

It doesn’t work, is this my problem?

Output:
‎ 16:15:22.745 cloud_336673829.PluginImporterPlugin.Libraries.PluginImporter:95: HTTP 409 (Conflict) - Edit
‎ 16:15:22.745 Stack Begin - Studio
‎ 16:15:22.745 Script ‘cloud_336673829.PluginImporterPlugin.Libraries.PluginImporter’, Line 95 - function ImportPlugin - Studio
‎ 16:15:22.746 Script ‘cloud_336673829.PluginImporterPlugin.Core.Components.RecentsPage.ResultsCanvas’, Line 21 - function Clicked - Studio
‎ 16:15:22.746 Script ‘cloud_336673829.PluginImporterPlugin.Packages.Roact.SingleEventManager’, Line 83 - Studio
‎ 16:15:22.746 Stack End - Studio

local DSServ = game:GetService("DataStoreService")

local pages = DSServ:ListDataStoresAsync() -- Get datastore pages
				
while wait() do
	for _, item in ipairs(pages:GetCurrentPage()) do -- List Datastores on current page
		print(item.DataStoreName) -- Print Datastore name
	end
	if pages.IsFinished then break end -- Stop listing if this is the last page
	pages:AdvanceToNextPageAsync() -- Go to next page
end
2 Likes