Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

DataStore - get all keys to go in a for loop?

So I have a basic datastore:

local dataStore = game:GetService("DataStoreService"):GetDataStore("Example")

How can I get all the keys to do this:

for i, v in pairs(dataStore) do
	print("Key: " ..v)
end

I don't have any of the key names, so I can't do GetAsync().

2 comments

0

I guess the first thought that popped into my mind would be to save all the keys with a "Skeleton Key", thing. Then you could loop through, using all the keys saved to the main key, and get the information from those keys. I would like to see if there are better methods to do this, though. Good question.

0

Yeah, although there will be a string limit at one point.

1 answer

Unless you make the datastore as one key with one value which is a table, you can't loop through a datastore. It is meant to get data for specific players. If you are only concerned with data for players in the current server, you should make a simple table called "localDataStore" or something. When the player joins, store their data in that table. Then you can loop through data.

This discussion is preserved as it was. New answers, comments, and votes are closed.