# On Variable Change

Executed when the State Machine Variable is modified.

## Description

This event fires whenever a variable on a State Machine asset is changed. Use this to react to global state changes across all instances.

## Parameters

| Name         | Description                         |
| ------------ | ----------------------------------- |
| **Variable** | The variable to monitor for changes |

## Keywords

`Variable`, `Change`, `State Machine`

## Example

```
Trigger Component:
├─ Event: On State Machine Variable Change
│   └─ Variable: "GameMode"
└─ Actions:
    └─ Update UI to reflect new game mode
```

{% hint style="info" %}
Use this event for global variables that affect the entire game, such as game mode, difficulty settings, or global unlocks.
{% endhint %}

{% hint style="warning" %}
This monitors **asset-level** variables. For per-instance variables, use **On State Machine Runner Variable Change** instead.
{% endhint %}


---

# 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.ninjutsugames.com/game-creator-2/state-machine-2/visual-scripting/events/on-variable-change.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.
