10 min read

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

NameType / ReturnsDescription
DataStore:GetVersionAsyncTupleRetrieves the specified key version.
DataStore:GetVersionAtTimeAsyncTupleRetrieves the key version that was current at a given time.
DataStore:ListKeysAsyncDataStoreKeyPagesReturns a DataStoreKeyPages object for enumerating through keys of a data store.
DataStore:ListVersionsAsyncDataStoreVersionPagesEnumerates all versions of a key.
DataStore:RemoveVersionAsync()Permanently deletes the specified version of a key.

Inherited from GlobalDataStore

NameType / ReturnsDescription
GlobalDataStore:BatchGetAsyncDictionaryReturns the values of multiple keys from the data store in a single request.
GlobalDataStore:GetAsyncTupleReturns the value of a key in a specified data store and a DataStoreKeyInfo instance.
GlobalDataStore:IncrementAsyncVariantIncrements the value of a key by the provided amount (both must be integers).
GlobalDataStore:OnUpdateRBXScriptConnectionSets a callback function to be executed any time the value associated with a key is changed.
GlobalDataStore:RemoveAsyncTupleRemoves the specified key while also retaining an accessible version.
GlobalDataStore:SetAsyncVariantSets the value of the data store for the given key.
GlobalDataStore:UpdateAsyncTupleUpdates a key's value with a new value from the specified callback function.

Inherited from Instance

NameType / ReturnsDescription
Instance:AddTag()Applies a tag to the instance.
Instance:childrenInstancesReturns an array of the object's children.
Instance:ClearAllChildren()This method destroys all of an instance's children.
Instance:CloneInstanceCreate a copy of an instance and all its descendants, ignoring instances that are not Archivable.
Instance:cloneInstance
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:FindFirstAncestorInstance?Returns the first ancestor of the Instance whose Instance.Name is equal to the given name.
Instance:FindFirstAncestorOfClassInstance?Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className.
Instance:FindFirstAncestorWhichIsAInstance?Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstChildInstance?Returns the first child of the Instance found with the given name.
Instance:findFirstChildInstance
Instance:FindFirstChildOfClassInstance?Returns the first child of the Instance whose ClassName is equal to the given class name.
Instance:FindFirstChildWhichIsAInstance?Returns the first child of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstDescendantInstance?Returns the first descendant found with the given Instance.Name.
Instance:GetActorActor?Returns the Actor associated with the Instance, if any.
Instance:GetAttributeVariantReturns the value which has been assigned to the given attribute name.
Instance:GetAttributeChangedSignalRBXScriptSignalReturns an event that fires when the given attribute changes.
Instance:GetAttributesDictionaryReturns a dictionary of the instance's attributes.
Instance:GetChildrenInstancesReturns an array containing all of the instance's children.
Instance:getChildrenInstances
Instance:GetDebugIdstringReturns a coded string of the debug ID used internally by Roblox.
Instance:GetDescendantsInstancesReturns an array containing all of the descendants of the instance.
Instance:GetFullNamestringReturns a string describing the instance's ancestry.
Instance:GetStyledVariantReturns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified.
Instance:GetStyledPropertyChangedSignalRBXScriptSignalReturns an event that fires when the given style property changes on the instance.
Instance:GetTagsArrayGets an array of all tags applied to the instance.
Instance:HasTagbooleanCheck whether the instance has a given tag.
Instance:IsAncestorOfbooleanReturns true if an Instance is an ancestor of the given descendant.
Instance:IsDescendantOfbooleanReturns true if an Instance is a descendant of the given ancestor.
Instance:isDescendantOfboolean
Instance:IsPropertyModifiedbooleanReturns true if the value stored in the specified property is not equal to the code-instantiated default.
Instance:QueryDescendantsInstancesReturns 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:WaitForChildInstanceReturns 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

NameType / ReturnsDescription
Object:GetPropertyChangedSignalRBXScriptSignalGet an event that fires when a given property of the object changes.
Object:IsAbooleanReturns true if an object's class matches or inherits from a given class.
Object:isAboolean

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

NameTypeDefaultDescription
keystringKey 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".
versionstringVersion number of the key for which the version info is requested.

Returns

TypeDescription
TupleThe 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.
FieldValue
tags["Yields"]
securityNone
thread safetyUnsafe
capabilities["DataStore"]

DataStore:GetVersionAtTimeAsync

This function retrieves the key version that was current at a given time as well as a DataStoreKeyInfo instance.

Parameters

NameTypeDefaultDescription
keystringKey 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".
timestampint64Unix 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
TupleThe 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.
FieldValue
tags["Yields"]
securityNone
thread safetyUnsafe
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

NameTypeDefaultDescription
prefixstring(Optional) Prefix to use for locating keys.
pageSizeint0(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.
cursorstring(Optional) Cursor to continue iteration.
excludeDeletedbooleanfalse(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
DataStoreKeyPagesA DataStoreKeyPages instance that enumerates the keys as DataStoreKey instances.
FieldValue
tags["Yields"]
securityNone
thread safetyUnsafe
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

NameTypeDefaultDescription
keystringKey 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".
sortDirectionSortDirectionAscending(Optional) Enum specifying ascending or descending sort order.
minDateint640(Optional) Unix timestamp in milliseconds after which the versions should be listed.
maxDateint640(Optional) Unix timestamp in milliseconds up to which the versions should be listed.
pageSizeint0(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
DataStoreVersionPagesA DataStoreVersionPages instance that enumerates all the versions of the key as DataStoreObjectVersionInfo instances.
FieldValue
tags["Yields"]
securityNone
thread safetyUnsafe
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

NameTypeDefaultDescription
keystringKey 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".
versionstringVersion number of the key to remove.

Returns

TypeDescription
()
FieldValue
tags["Yields","Deprecated"]
securityNone
thread safetyUnsafe
capabilities["DataStore"]

Properties

Inherited from Instance

NameType / ReturnsDescription
Instance.ArchivablebooleanDetermines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published.
Instance.archivableboolean
Instance.CapabilitiesSecurityCapabilitiesThe set of capabilities allowed to be used for scripts inside this container.
Instance.IsInSandboxbooleanIndicates whether the instance is inside a sandboxed container.
Instance.NamestringA non-unique identifier of the Instance.
Instance.ParentInstanceDetermines the hierarchical parent of the Instance.
Instance.PredictionModePredictionModeReflects the client-side prediction mode applied to the instance under server-authoritative physics.
Instance.RobloxLockedbooleanA deprecated property that used to protect CoreGui objects.
Instance.SandboxedbooleanWhen enabled, the instance can only access abilities in its Capabilities list.
Instance.UniqueIdUniqueIdA unique identifier for the instance.

Inherited from Object

NameType / ReturnsDescription
Object.ClassNamestringA read-only string representing the class this Object belongs to.
Object.classNamestring

Events

Inherited from Instance

NameType / ReturnsDescription
Instance.AncestryChangedFires when the Instance.Parent property of this object or one of its ancestors is changed.
Instance.AttributeChangedFires whenever an attribute is changed on the Instance.
Instance.ChildAddedFires after an object is parented to this Instance.
Instance.childAdded
Instance.ChildRemovedFires after a child is removed from this Instance.
Instance.DescendantAddedFires after a descendant is added to the Instance.
Instance.DescendantRemovingFires immediately before a descendant of the Instance is removed.
Instance.DestroyingFires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy().
Instance.StyledPropertiesChangedFires whenever any style property is changed on the instance, including when a property is set to nil.

Inherited from Object

NameType / ReturnsDescription
Object.ChangedFires immediately after a property of the object changes, with some limitations.