PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

RemoveAsync

This function marks the specified key as deleted by creating a new “tombstone” version of the key. Prior to this, it returns the latest version prior to the remove call.

After a key is removed via this function, GlobalDataStore/GetAsync calls for the key will return nil. Older versions of the key remain accessible through DataStore/ListVersionsAsync and DataStore/GetVersionAsync, assuming they have not expired.

OrderedDataStore does not support versioning, so calling GlobalDataStore/RemoveAsync|RemoveAsync() on an OrderedDataStore key will permanently delete it.

See Also

  • Articles/Data store|Data Stores, an in-depth guide on data structure, management, error handling, etc.

Parameters

Name Type Default Description

key

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

Return Type Summary

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 Player/UserId|UserIds and metadata.


Code Samples


Remove Data Store Key/Value

local DataStoreService = game:GetService("DataStoreService")

local nicknameStore = DataStoreService:GetDataStore("Nicknames")

local success, removedValue, keyInfo = pcall(function()
	return nicknameStore:RemoveAsync("User_1234")
end)
if success then
	print(removedName)
	print(keyInfo.Version)
	print(keyInfo.CreatedTime)
	print(keyInfo.UpdatedTime)
	print(keyInfo:GetUserIds())
	print(keyInfo:GetMetadata())
end