Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
DataStore
Inherits from: GlobalDataStore → Instance → Object
See Data stores for an in-depth guide on data structure, management, error handling, limits, and more.
Inherits from: GlobalDataStore
Memory category: Instances
Tags: NotCreatable, NotReplicated
Methods
| Name | Type / Returns | Description |
|---|---|---|
| DataStore:GetVersionAsync | Tuple | Retrieves the specified key version. |
| DataStore:GetVersionAtTimeAsync | Tuple | Retrieves the key version that was current at a given time. |
| DataStore:ListKeysAsync | DataStoreKeyPages | Returns a DataStoreKeyPages object for enumerating through keys of a data store. |
| DataStore:ListVersionsAsync | DataStoreVersionPages | Enumerates all versions of a key. |
| DataStore:RemoveVersionAsync | () | Permanently deletes the specified version of a key. |
Inherited from GlobalDataStore
| Name | Type / Returns | Description |
|---|---|---|
| GlobalDataStore:BatchGetAsync | Dictionary | Returns the values of multiple keys from the data store in a single request. |
| GlobalDataStore:GetAsync | Tuple | Returns the value of a key in a specified data store and a DataStoreKeyInfo instance. |
| GlobalDataStore:IncrementAsync | Variant | Increments the value of a key by the provided amount (both must be integers). |
| GlobalDataStore:OnUpdate | RBXScriptConnection | Sets a callback function to be executed any time the value associated with a key is changed. |
| GlobalDataStore:RemoveAsync | Tuple | Removes the specified key while also retaining an accessible version. |
| GlobalDataStore:SetAsync | Variant | Sets the value of the data store for the given key. |
| GlobalDataStore:UpdateAsync | Tuple | Updates a key's value with a new value from the specified callback function. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance:AddTag | () | Applies a tag to the instance. |
| Instance:children | Instances | Returns an array of the object's children. |
| Instance:ClearAllChildren | () | This method destroys all of an instance's children. |
| Instance:Clone | Instance | Create a copy of an instance and all its descendants, ignoring instances that are not Archivable. |
| Instance:clone | Instance | |
| Instance:Destroy | () | Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children. |
| Instance:destroy | () | |
| Instance:FindFirstAncestor | Instance? | Returns the first ancestor of the Instance whose Instance.Name is equal to the given name. |
| Instance:FindFirstAncestorOfClass | Instance? | Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className. |
| Instance:FindFirstAncestorWhichIsA | Instance? | Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className. |
| Instance:FindFirstChild | Instance? | Returns the first child of the Instance found with the given name. |
| Instance:findFirstChild | Instance | |
| Instance:FindFirstChildOfClass | Instance? | Returns the first child of the Instance whose ClassName is equal to the given class name. |
| Instance:FindFirstChildWhichIsA | Instance? | Returns the first child of the Instance for whom Object:IsA() returns true for the given className. |
| Instance:FindFirstDescendant | Instance? | Returns the first descendant found with the given Instance.Name. |
| Instance:GetActor | Actor? | Returns the Actor associated with the Instance, if any. |
| Instance:GetAttribute | Variant | Returns the value which has been assigned to the given attribute name. |
| Instance:GetAttributeChangedSignal | RBXScriptSignal | Returns an event that fires when the given attribute changes. |
| Instance:GetAttributes | Dictionary | Returns a dictionary of the instance's attributes. |
| Instance:GetChildren | Instances | Returns an array containing all of the instance's children. |
| Instance:getChildren | Instances | |
| Instance:GetDebugId | string | Returns a coded string of the debug ID used internally by Roblox. |
| Instance:GetDescendants | Instances | Returns an array containing all of the descendants of the instance. |
| Instance:GetFullName | string | Returns a string describing the instance's ancestry. |
| Instance:GetStyled | Variant | Returns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified. |
| Instance:GetStyledPropertyChangedSignal | RBXScriptSignal | Returns an event that fires when the given style property changes on the instance. |
| Instance:GetTags | Array | Gets an array of all tags applied to the instance. |
| Instance:HasTag | boolean | Check whether the instance has a given tag. |
| Instance:IsAncestorOf | boolean | Returns true if an Instance is an ancestor of the given descendant. |
| Instance:IsDescendantOf | boolean | Returns true if an Instance is a descendant of the given ancestor. |
| Instance:isDescendantOf | boolean | |
| Instance:IsPropertyModified | boolean | Returns true if the value stored in the specified property is not equal to the code-instantiated default. |
| Instance:QueryDescendants | Instances | Returns an array containing all descendants of the instance that match the selector string. |
| Instance:Remove | () | Sets the object's Parent to nil, and does the same for all its descendants. |
| Instance:remove | () | |
| Instance:RemoveTag | () | Removes a tag from the instance. |
| Instance:ResetPropertyToDefault | () | Resets a property to its default value. |
| Instance:SetAttribute | () | Sets the attribute with the given name to the given value. |
| Instance:WaitForChild | Instance | Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object:GetPropertyChangedSignal | RBXScriptSignal | Get an event that fires when a given property of the object changes. |
| Object:IsA | boolean | Returns true if an object's class matches or inherits from a given class. |
| Object:isA | boolean |
DataStore:GetVersionAsync
This function retrieves the specified key version as well as a DataStoreKeyInfo instance. A version identifier can be found through DataStore:ListVersionsAsync() or alternatively be the identifier returned by GlobalDataStore:SetAsync().
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| 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
| Type | Description |
|---|---|
| Tuple | 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. |
| Field | Value |
|---|---|
| tags | ["Yields"] |
| security | None |
| thread safety | Unsafe |
| capabilities | ["DataStore"] |
DataStore:GetVersionAtTimeAsync
This function retrieves the key version that was current at a given time as well as a DataStoreKeyInfo instance.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| 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 | int64 | 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
| Type | Description |
|---|---|
| Tuple | 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. |
| Field | Value |
|---|---|
| tags | ["Yields"] |
| security | None |
| thread safety | Unsafe |
| capabilities | ["DataStore"] |
Code samples: View on Creator Hub (retrieving-datastore-versions-by-time).
DataStore:ListKeysAsync
This function returns a DataStoreKeyPages object for enumerating through keys of a data store. It accepts an optional prefix parameter to only locate keys whose names start with the provided prefix.
If DataStoreOptions.AllScopes was set to true when accessing the data store through DataStoreService:GetDataStore(), keys will be returned with all scopes as prefixes.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| prefix | string | (Optional) Prefix to use for locating keys. | |
| pageSize | int | 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
| Type | Description |
|---|---|
| DataStoreKeyPages | A DataStoreKeyPages instance that enumerates the keys as DataStoreKey instances. |
| Field | Value |
|---|---|
| tags | ["Yields"] |
| security | None |
| thread safety | Unsafe |
| capabilities | ["DataStore"] |
DataStore:ListVersionsAsync
This function enumerates versions of the specified key in either ascending or descending order specified by a SortDirection parameter. It can optionally filter the returned versions by minimum and maximum timestamp.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| 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 | SortDirection | Ascending | (Optional) Enum specifying ascending or descending sort order. |
| minDate | int64 | 0 | (Optional) Unix timestamp in milliseconds after which the versions should be listed. |
| maxDate | int64 | 0 | (Optional) Unix timestamp in milliseconds up to which the versions should be listed. |
| pageSize | int | 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
| Type | Description |
|---|---|
| DataStoreVersionPages | A DataStoreVersionPages instance that enumerates all the versions of the key as DataStoreObjectVersionInfo instances. |
| Field | Value |
|---|---|
| tags | ["Yields"] |
| security | None |
| thread safety | Unsafe |
| capabilities | ["DataStore"] |
Code samples: View on Creator Hub (retrieving-datastore-versions-with-a-date-filter).
DataStore:RemoveVersionAsync
Deprecated. This method is deprecated. Do not use it for new work.
This function permanently deletes the specified version of a key. Version identifiers can be found through DataStore:ListVersionsAsync().
Unlike GlobalDataStore:RemoveAsync(), this function does not create a new "tombstone" version and the removed value cannot be retrieved later.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| 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. |
Returns
| Type | Description |
|---|---|
| () |
| Field | Value |
|---|---|
| tags | ["Yields","Deprecated"] |
| security | None |
| thread safety | Unsafe |
| capabilities | ["DataStore"] |
Properties
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance.Archivable | boolean | Determines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published. |
| Instance.archivable | boolean | |
| Instance.Capabilities | SecurityCapabilities | The set of capabilities allowed to be used for scripts inside this container. |
| Instance.IsInSandbox | boolean | Indicates whether the instance is inside a sandboxed container. |
| Instance.Name | string | A non-unique identifier of the Instance. |
| Instance.Parent | Instance | Determines the hierarchical parent of the Instance. |
| Instance.PredictionMode | PredictionMode | Reflects the client-side prediction mode applied to the instance under server-authoritative physics. |
| Instance.RobloxLocked | boolean | A deprecated property that used to protect CoreGui objects. |
| Instance.Sandboxed | boolean | When enabled, the instance can only access abilities in its Capabilities list. |
| Instance.UniqueId | UniqueId | A unique identifier for the instance. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object.ClassName | string | A read-only string representing the class this Object belongs to. |
| Object.className | string |
Events
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance.AncestryChanged | Fires when the Instance.Parent property of this object or one of its ancestors is changed. | |
| Instance.AttributeChanged | Fires whenever an attribute is changed on the Instance. | |
| Instance.ChildAdded | Fires after an object is parented to this Instance. | |
| Instance.childAdded | ||
| Instance.ChildRemoved | Fires after a child is removed from this Instance. | |
| Instance.DescendantAdded | Fires after a descendant is added to the Instance. | |
| Instance.DescendantRemoving | Fires immediately before a descendant of the Instance is removed. | |
| Instance.Destroying | Fires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy(). | |
| Instance.StyledPropertiesChanged | Fires whenever any style property is changed on the instance, including when a property is set to nil. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object.Changed | Fires immediately after a property of the object changes, with some limitations. |