> For the complete documentation index, see [llms.txt](https://kno.gitbook.io/ezmodules/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kno.gitbook.io/ezmodules/data-handler/installation.md).

# Installation

### Installation

To use the DataHandler module in your Roblox game, you have two options: using a model from the Roblox Creator Marketplace or directly requiring it using its asset ID.

#### Option 1: Using the Model

1. **Get the Model**: Visit the Roblox Creator Marketplace and search for the DataHandler module or use the direct link: DataHandler Module.
2. **Insert the Model**: Insert the model into your game.
3. **Place in ReplicatedStorage**: Move the model into `ReplicatedStorage`. You can place it in a folder if you like, but ensure the path in your script matches the folder structure.

#### Option 2: Direct Asset ID

If you prefer not to use the model, you can directly require the module using its asset ID:

```lua
local DataHandler = require(108002867325509)
```

### Configuration

Before using DataHandler, you should configure it to match your game's requirements. Here’s how you can set it up:

```lua
local DataHandler = require(game.ReplicatedStorage:WaitForChild("DataHandler"))

-- Update the configuration with the desired values
DataHandler.Config = {
    DataStoreName = "PlayerDataStore", -- Name of the DataStore for player data
    Keys = {"stats"}, -- Keys to load for a player
    LeaderStats = {} -- Table for leader stats
}
```

### Functions

#### `DataHandler:SaveData(player, key, value)`

* **player**: The player whose data you want to save.
* **key**: The key under which the data is saved.
* **value**: The data to save.

#### `DataHandler:LoadData(userId, key)`

* **userId**: The ID of the player whose data you want to load.
* **key**: The key of the data to load.
* Returns the data or `nil` if an error occurs.

#### `DataHandler:DeleteData(userId, key)`

* **userId**: The ID of the player whose data you want to delete.
* **key**: The key of the data to delete.

#### `DataHandler:GetPlayerData(userId)`

* **userId**: The ID of the player whose data you want to get.
* Returns a table of data for the player.

#### `DataHandler:CreateLeaderStats(player, statsTable)`

* **player**: The player for whom to create leader stats.
* **statsTable**: A table where the keys are stat names and the values are types ("IntValue", "NumberValue", "StringValue").
