Datastore: why (and when) to use scopes?

For example, to store player data, I could have only one DataStore and each player is a key, and all player data is inside a multilevel dictionary.

local DataStoreService = game:GetService("DataStoreService")
local PlayersStore = DataStoreService:GetDataStore("PlayerStore")
local UserTable = PlayersStore:GetAsync("User_1234") --< all data from UserId 1234

I think scope would be just a kind of filter.
In this case, I could filter the data (via script) directly on the table I already have, without the need for a scope.

So what is the advantage (if any) of using scope?

1 Like

Can you explain in detail please?

Advantages may be looping through all the players if you want to perform an action on all of them for example diving money or wiping the data

1 Like

But I could do the same without scopes…

You aren’t able to loop through datastore keys. How would you do that?

for i, v in pairs(DataStore:GetAsync(key?)) do


Oh you were talking about this, then scopes as dictionaries could be usefull to do the same thing but for values in an array

There isn’t an advantage to using scopes. I believe not even internally. They’re just a way to separate DataStores with the same name.

Functionality wise, doing :GetDataStore("Name_Scope") or :GetDataStore("Name", "Scope") is the same.