How does scope in DataStores work?

Scopes are just used to partition data into other sections. Think of them like subfolders in a DataStore. When you don’t specify a scope, your DataStore actually still uses a scope - the default scope, which is “global”. Specifying a scope puts a DataStore at the same level as one without it.

DataStoreService
 DataStoreName
  DataStoreKey
 DataStoreName Scope_global
  DataStoreKey
 DataStoreName Scope_safe1
  DataStoreKey

Think of it like your computer’s file system.

When you get a DataStore, you open up the main folder which is the first string you specify to GetDataStore. When you don’t specify a scope, it defaults to global and opens the global subfolder. If you specify a scope, it creates and opens the new folder which is the scope you set.

50 Likes