Skip to content
Roblox API Reference

DataStore

A GlobalDataStore that also supports versioning, key metadata, and enumerating keys.
  • Not creatable
  • Not replicated
Memory category
Instances
Own members
5
Inherited members
82
Subclasses
0
Siblings
2

Properties23

Inherited fromObject2

Property categoryData

Inherited fromInstance21

Property categoryBehavior

Property categoryData

Property categoryPermissions

Methods54

Inherited fromObject3
  • Get an event that fires when a given property of the object changes.
    Parameters
    ParameterDescription
    property: string
    The property to connect to.
    Returns
    TypeDescription
    RBXScriptSignal
    A signal that fires whenever the property changes.
  • Object:IsA(className: string): boolean
    Returns true if an object's class matches or inherits from a given class.
    • Custom Lua state
    • Thread safe
    Parameters
    ParameterDescription
    className: string
    The class against which the Object's class will be checked. Case-sensitive.
    Returns
    TypeDescription
    boolean
    Describes whether the Object's class matched or is a subclass of the given class.
  • Object:isA(className: string): boolean
    Deprecated: This deprecated function is a variant of Object:IsA() which should be used instead.
    • Deprecated
    • Custom Lua state
    Parameters
    Parameter
    className: string
    Returns
    Type
    boolean

    Use IsA instead.

Inherited fromInstance39
Inherited fromGlobalDataStore7
  • Returns the values of multiple keys from the data store in a single request.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    keys: { any }
    An array of key name strings to retrieve. The maximum number of keys per request is determined by a server-side limit (default 100).
    options: { [string]: any }? = nil
    (Optional) Unused; has no effect.
    Returns
    TypeDescription
    { [string]: any }
    A dictionary mapping each requested key (string) to a table containing a value field with the key's current value. Keys that don't exist or have no value are omitted from the result.
  • Returns the value of a key in a specified data store and a DataStoreKeyInfo instance.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    The key name for which the value is requested. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    options: DataStoreGetOptions? = nil
    (Optional) A DataStoreGetOptions instance that controls aspects of the read, such as whether to bypass the locally cached value via its DataStoreGetOptions.UseCache property.
    Returns
    TypeDescription
    ...any
    The value of the entry in the data store with the given key and a DataStoreKeyInfo instance that includes the version number, date and time the version was created, and functions to retrieve UserIds and metadata.
  • GlobalDataStore:IncrementAsync(key: string,delta: number? = 1,userIds: { any }? = {},options: DataStoreIncrementOptions? = nil,): any
    Increments the value of a key by the provided amount (both must be integers).
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    Key name for which the value should be updated. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    delta: number? = 1
    Amount to increment the current value by.
    userIds: { any }? = {}
    (Optional) A table of UserIds to associate with the key.
    options: DataStoreIncrementOptions? = nil
    (Optional)DataStoreIncrementOptions instance that combines multiple additional parameters as custom metadata and allows for future extensibility.
    Returns
    TypeDescription
    any
    The updated value of the entry in the data store with the given key.
  • Removes the specified key while also retaining an accessible version.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    Key name to be removed. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    Returns
    TypeDescription
    ...any
    The value of the data store prior to deletion and a DataStoreKeyInfo instance that includes the version number, date and time the version was created, and functions to retrieve UserIds and metadata.
  • GlobalDataStore:SetAsync(key: string,value: any,userIds: { any }? = {},options: DataStoreSetOptions? = nil,): any
    Sets the value of the data store for the given key.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    Key name for which the value should be set. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    value: any
    The value that the data store key will be set to.
    userIds: { any }? = {}
    Table of UserIds, highly recommended to assist with GDPR tracking/removal.
    options: DataStoreSetOptions? = nil
    (Optional)DataStoreSetOptions instance that allows for metadata specification on the key.
    Returns
    TypeDescription
    any
    The version identifier of the newly created version. It can be used to retrieve key info using GetVersionAsync() or to remove it using RemoveVersionAsync().
  • Updates a key's value with a new value from the specified callback function.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    Key name for which the value should be updated. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    transformFunction: (...any) -> ...any
    Transform function that takes the current value and DataStoreKeyInfo as parameters and returns the new value along with optional UserIds and metadata.
    Returns
    TypeDescription
    ...any
    The updated value of the entry in the data store with the given key and a DataStoreKeyInfo instance that includes the version number, date and time the version was created, and functions to retrieve UserIds and metadata.
  • Deprecated: This function has been deprecated and should not be used in new work. You can use the Cross Server Messaging Service to publish and subscribe to topics to receive near real-time updates, completely replacing the need for this function.
    Sets a callback function to be executed any time the value associated with a key is changed.
    • Deprecated
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    The key identifying the entry being retrieved from the data store.
    callback: (...any) -> ...any
    The function to be executed any time the value associated with key is changed.
    Returns
    TypeDescription
    RBXScriptConnection
    The connection to the key being tracked for updates.
Defined byDataStore5
  • DataStore:GetVersionAsync(key: string, version: string): ...any
    Retrieves the specified key version.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    Key name for which the version info is requested. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    version: string
    Version number of the key for which the version info is requested.
    Returns
    TypeDescription
    ...any
    The value of the key at the specified version and a DataStoreKeyInfo instance that includes the version number, date and time the version was created, and functions to retrieve UserIds and metadata.
  • DataStore:GetVersionAtTimeAsync(key: string, timestamp: number): ...any
    Retrieves the key version that was current at a given time.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    Key name for which the version info is requested. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    timestamp: number
    Unix timestamp in milliseconds for which the requested version was current. Must be greater than zero. Must not be more than ten minutes in the future.
    Returns
    TypeDescription
    ...any
    The value of the key that was current at the specified time and a DataStoreKeyInfo instance that includes the version number, date and time the version was created, and functions to retrieve UserIds and metadata. nil if no available version was current at the requested time.
  • DataStore:ListKeysAsync(prefix: string? = "",pageSize: number? = 0,cursor: string? = "",excludeDeleted: boolean? = false,): DataStoreKeyPages
    Returns a DataStoreKeyPages object for enumerating through keys of a data store.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    prefix: string? = ""
    (Optional) Prefix to use for locating keys.
    pageSize: number? = 0
    (Optional) Number of items to be returned in each page. If no value is given, the engine sends a default value of 0 to the data store web service, which in turn defaults to 50 items per page.
    cursor: string? = ""
    (Optional) Cursor to continue iteration.
    excludeDeleted: boolean? = false
    (Optional) Exclude deleted keys from being returned. When enabled ListKeys will check up to 512 keys. If all checked keys are deleted then it will return an empty list with a cursor to continue iteration.
    Returns
    TypeDescription
    DataStoreKeyPages
    A DataStoreKeyPages instance that enumerates the keys as DataStoreKey instances.
  • DataStore:ListVersionsAsync(key: string,sortDirection: Enum.SortDirection? = Enum.SortDirection.Ascending,minDate: number? = 0,maxDate: number? = 0,pageSize: number? = 0,): DataStoreVersionPages
    Enumerates all versions of a key.
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    Key name for the versions to list. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    sortDirection: Enum.SortDirection? = Enum.SortDirection.Ascending
    (Optional) Enum specifying ascending or descending sort order.
    minDate: number? = 0
    (Optional) Unix timestamp in milliseconds after which the versions should be listed.
    maxDate: number? = 0
    (Optional) Unix timestamp in milliseconds up to which the versions should be listed.
    pageSize: number? = 0
    (Optional) Number of items to be returned in each page. If no value is given, the engine sends a default value of 0 to the data store web service, which in turn defaults to 1024 items per page.
    Returns
    TypeDescription
    DataStoreVersionPages
    A DataStoreVersionPages instance that enumerates all the versions of the key as DataStoreObjectVersionInfo instances.
  • DataStore:RemoveVersionAsync(key: string, version: string)
    Deprecated: This method is deprecated. Do not use it for new work.
    Permanently deletes the specified version of a key.
    • Deprecated
    • Yields
    • Capabilities: DataStore
    Parameters
    ParameterDescription
    key: string
    Key name for which a version is to be removed. If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), this key name must be prepended with the original scope as in "scope/key".
    version: string
    Version number of the key to remove.

Events10

Inherited fromObject1
Inherited fromInstance9