---
title: "Visual Scripting Variables"
description: "Variables are typed values owned by a script. They are useful for counters, cooldowns, state flags, and cached values that should survive from one handler dispatch to the next."
engineVersion: v1.0.234
date: 2026-09-28
license: "(c) Gessa, proprietary. Cite with attribution to https://gessa.ai/docs/. Terms: https://gessa.ai/terms/."
canonical: https://gessa.ai/docs/creator/visual-scripting-variables/
---
# Visual Scripting Variables

Variables are typed values owned by a script. They are useful for counters,
cooldowns, state flags, and cached values that should survive from one handler
dispatch to the next.

## Authoring

- Create variables in the Variables panel.
- Use Get Variable nodes to read values.
- Use Set Variable nodes to update mutable values.
- Use immutable variables for constants that should not be changed by the
  graph.

Each variable has a name, type, mutability flag, and default value.

## Runtime Behavior

Runtime stores variable values outside the QuickJS VM, keyed by the room,
entity, script, and variable. A value persists across handler dispatches for the
same entity and script. Values reset when the room closes, the entity despawns,
or the variable schema changes.

Body-only script edits preserve compatible values. Adding, removing, renaming,
or changing a variable type resets that script's variable state for the entity.

## SDK Access

Generated scripts use the same backing store through:

```ts
const current = ctx.script.variables.score.get();
ctx.script.variables.score.set(current + 1);
```

Advanced scripts can target another script on an entity when that script exists
in the runtime catalog:

```ts
ctx.entity("enemy_1")?.script("health")?.variables.hp.set(0);
```
