> For the complete documentation index, see [llms.txt](https://laot7490.gitbook.io/ltbridge/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://laot7490.gitbook.io/ltbridge/utilities/cache/on-change.md).

# OnChange

Listen for changes in cache values.

{% hint style="info" %}
**Side:** Client · **Category:** Cache · **API:** `LT.Cache.OnChange`
{% endhint %}

## Example

```lua
LT.Cache.OnChange('vehicle', function(vehicle, oldVehicle)
    print('Vehicle state changed', vehicle)
end)
```

## Parameters

| Name  | Required | Description                                                       |
| ----- | -------- | ----------------------------------------------------------------- |
| `key` | Yes      | Cache key: `'ped'`, `'vehicle'`, `'seat'`, `'weapon'`, `'isDead'` |
| `cb`  | Yes      | fun(newValue: any, oldValue: any)                                 |
