# DataStoreService

DataStoreService : `Instance`

## Overview

DataStoreService provides access to data storage in server environment.

## Properties

## Methods

### GetDataStore

Creates a new DataStore object based on the provided name and returns it. If it is called again with the same name, it reuses previously created instance.

#### Parameters

| `string` InName     | The name of a DataStore object.                                                                                                            |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `string` InScope    | A scope string used to distinguish keys within the DataStore. It can be left empty, and when provided, must be 50 characters or less.      |
| `Instance` InOption | An option instance used to specify additional behavior when creating the DataStore. If not specified, it is created with default settings. |

#### Return

| `GlobalDataStore` | The returned DataStore object. |
| ----------------- | ------------------------------ |

#### Code Samples

```lua
local DataStoreService = game:GetService("DataStoreService")
local GoldStore = DataStoreService:GetDataStore("PlayerGold")
```

### GetGlobalDataStore

Returns default global data store provided by system. The GetDataStore function must be used to access a separate data storage with a specific name.

#### Parameters

#### Return

| `GlobalDataStore` | The returned GlobalDataStore object. |
| ----------------- | ------------------------------------ |

#### Code Samples

```lua
local DataStoreService = game:GetService("DataStoreService")
local GlobalStore = DataStoreService:GlobalDataStore()
```

## Events

## See also

{% content-ref url="/pages/UhMJ4cZ06n5d2vzza3Pw" %}
[Saving & Loading Data](/manual/script-manual/advanced-gameplay-systems/datastore.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overdare.com/development/api-reference/classes/datastoreservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
