# Auxvyn.startLiveSync()

### Syntax

```lua
Auxvyn.startLiveSync(onUpdate: ((userId: string, key: string, value: any, player: Player?) -> ())?)
```

***

### Parameters

| Parameter  | Type     | Required   | Description                              |
| ---------- | -------- | ---------- | ---------------------------------------- |
| `onUpdate` | function | <h3>✗</h3> | Callback fired when a change is received |

#### Callback Parameters

| Parameter | Type    | Description                                                             |
| --------- | ------- | ----------------------------------------------------------------------- |
| `userId`  | string  | The Roblox user ID of the player whose data changed                     |
| `key`     | string  | The key that was updated                                                |
| `value`   | any     | The new value                                                           |
| `player`  | Player? | The Player object if they are currently in this server, otherwise `nil` |

***

### Example

```lua
Auxvyn.startLiveSync(function(userId, key, value, player)
    if not player then return end -- player not in this server

    if key == "coins" then
        player.leaderstats.Coins.Value = tonumber(value) or 0
    end

    if key == "banned" and value == true then
        player:Kick("You have been banned.")
    end
end)
```

***

### Requirements

Live Sync requires:

1. Your workspace has a **Roblox Open Cloud API key** saved in Settings → Live Sync
2. Your game is **published** — MessagingService does not work in Studio playtesting
3. **MessagingService** is available in your experience

***

### How It Works

1. Your game server subscribes to a workspace-scoped MessagingService topic on startup
2. When you edit a player record in the dashboard, Auxvyn publishes a message to that topic via the Roblox Open Cloud API
3. Every live server receives the message instantly
4. Each server checks if the affected player is present and fires your callback

One subscription covers all players, there is no per-player connection overhead.

***

### Stopping Live Sync

```lua
Auxvyn.stopLiveSync()
```

This disconnects the MessagingService subscription. You rarely need to call this manually the subscription is automatically cleaned up when the server shuts down.

***

### Studio Testing

Live Sync cannot be tested in Studio. MessagingService is disabled in Studio playtesting by Roblox. To test Live Sync you must publish your game and join from the Roblox app or website.

***

### What's Next


---

# 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://auxvyn.gitbook.io/auxvyn-docs/module/auxvyn.startlivesync.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.
