# DataStoreService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Not replicated, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/DataStoreService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/DataStoreService

A game service that gives access to persistent data storage across places in a game.

## Properties

### AutomaticRetry

```luau
DataStoreService.AutomaticRetry: boolean = true
```

- Tags: Not replicated, Local user security, Read capabilities: DataStore

### LegacyNamingScheme

```luau
DataStoreService.LegacyNamingScheme: boolean = false
```

- Tags: Deprecated, Hidden, Local user security, Read capabilities: DataStore

## Methods

### GetDataStore

```luau
DataStoreService:GetDataStore(name: string, scope: string? = "global", options: Instance? = nil): DataStore
```

- Tags: Capabilities: DataStore

Creates a [`DataStore`](https://rapi.sleaze.dev/classes/DataStore.md) instance with the provided name and scope.

Parameters:

- `name`: Name of the data store.
- `scope`: **(Optional)** A string specifying the scope.
- `options`: **(Optional)** A [`DataStoreOptions`](https://rapi.sleaze.dev/classes/DataStoreOptions.md) instance to enable experimental features and v2 API features.

Returns: A [`DataStore`](https://rapi.sleaze.dev/classes/DataStore.md) instance with provided name and optional scope.

### GetGlobalDataStore

```luau
DataStoreService:GetGlobalDataStore(): DataStore
```

- Tags: Capabilities: DataStore

Returns the default data store.

Returns: The default [`GlobalDataStore`](https://rapi.sleaze.dev/classes/GlobalDataStore.md) instance.

### GetOrderedDataStore

```luau
DataStoreService:GetOrderedDataStore(name: string, scope: string? = "global"): OrderedDataStore
```

- Tags: Capabilities: DataStore

Get an [`OrderedDataStore`](https://rapi.sleaze.dev/classes/OrderedDataStore.md) given a name and optional scope.

Parameters:

- `name`: Name of the ordered data store.
- `scope`: **(Optional)** A string specifying the scope. Default is "global".

Returns: An [`OrderedDataStore`](https://rapi.sleaze.dev/classes/OrderedDataStore.md) instance with the provided name and scope.

### GetRequestBudgetForRequestType

```luau
DataStoreService:GetRequestBudgetForRequestType(requestType: Enum.DataStoreRequestType): number
```

- Tags: Capabilities: DataStore

Returns the number of requests that can be made by the given request type.

Parameters:

- `requestType`: The `DataStoreRequestType` to check the budget for.

Returns: The number of data store requests that can currently be made for the specified request type.

### ListDataStoresAsync

```luau
DataStoreService:ListDataStoresAsync(prefix: string? = "", pageSize: number? = 0, cursor: string? = ""): DataStoreListingPages
```

- Tags: Yields, Capabilities: DataStore

Returns a [`DataStoreListingPages`](https://rapi.sleaze.dev/classes/DataStoreListingPages.md) object for enumerating through all of the experience's data stores.

Parameters:

- `prefix`: **(Optional)** Prefix to enumerate data stores that start with the given prefix.
- `pageSize`: **(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 32 items per page.
- `cursor`: **(Optional)** Cursor to continue iteration.

Returns: [`DataStoreListingPages`](https://rapi.sleaze.dev/classes/DataStoreListingPages.md) instance containing [`DataStoreInfo`](https://rapi.sleaze.dev/classes/DataStoreInfo.md) instances that provide details such as name, creation time, and time last updated.

### SetRateLimitForRequestType

```luau
DataStoreService:SetRateLimitForRequestType(requestType: Enum.DataStoreRequestType, baseLimit: number, perPlayerLimit: number)
```

- Tags: Capabilities: DataStore

Sets the rate limit for a given request type per minute.

Parameters:

- `requestType`: The `DataStoreRequestType` to configure the rate limit for.
- `baseLimit`: The base number of requests allowed per minute regardless of player count.
- `perPlayerLimit`: The additional number of requests per minute granted for each connected player.

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
