> For the complete documentation index, see [llms.txt](https://docs.easy.gg/scripting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.easy.gg/scripting/bedwars-scripting/services/datastoreservice.md).

# DataStoreService

{% hint style="danger" %}
**WARNING:** Yielding in an [Event](/scripting/bedwars-scripting/events.md) will delay the outcome of the event. All DataStoreService functions WILL yield the current thread.

It is **highly recommended** to use `task.spawn()`around all DataStoreService functions. An example is provided below.&#x20;
{% endhint %}

Example usage:

```lua
-- Double the score of a player whenever they kill an entity
local function doubleScore(current)
    return current * 2
end

Events.EntityDeath(function (event)
    local killerPlayer = event.killer:getPlayer()
    if (killerPlayer == nil) then
        return
    end
    task.spawn(function()
        local currentValue = DataStoreService.getAsync(killerPlayer.userId)
        if (currentValue == nil) then
            currentValue = 1
        end
        DataStoreService.setAsync(killerPlayer.userId, doubleScore(currentValue))
    end)
end)
```

### Functions

#### getAsync(key: string | number): any

Returns the latest stored value for the given key.

#### setAsync(key: string | number, value: any): bool

Sets the latest value for the given key. Returns true if the network call was successful.

#### incrementAsync(key: string | number, amount: number): bool

Increases the current integer value for the given key by the given amount (must also be an integer value). Returns true if the network call was successful.

#### removeAsync(key: string | number): bool

Marks the given key as deleted. Returns true if the network call was successful.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.easy.gg/scripting/bedwars-scripting/services/datastoreservice.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
