Skip to main content

Variables

A variable is a labelled box that remembers a value for you: a score, a true/false flag, a player, a coordinate. These blocks set (write into the box) and get (read back out of the box). Variables are how your world remembers anything between one moment and the next.

The idea that matters most: scope

Before you use a variable, you pick its scope. Scope means who shares the box, and that one choice decides whether there is one box or many boxes. Think of a school:

  • Room Room: the score on the gym scoreboard. There's exactly one, and everyone sees the same number.
  • Player: each student's own locker. Same kind of locker, but the contents are private to that student. There's one box per player.
Block snippetThe two scopes at a glance. A room shares one box, while a player scope quietly keeps a separate box for each person.

You create your variables in the Variables panel (you give each one a name, a scope, and a type). After that, the blocks below read and write them. New to all this? Read Variables & memory for the full tour.

Renaming is always safe

Variables are tracked by a hidden ID, not by their name. Rename a variable any time, and every block that uses it keeps working.

Getting a value (reading)

Each scope has a get block, a value block you plug into a slot wherever you need the remembered value.

Room Variable ValueGet a room variable: the room's shared memory.
  • Room Variable Value reads the room's one shared value.
  • Player Variable Value reads one player's value. You tell it which player.
Player reads need an owner

A player variable has many boxes, so the get block has to know whose box to open. You snap a player into its socket, usually the triggering player (the one who set off the event). Leave that socket empty and the script won't publish: the editor flags a "missing input" error until you fill it.

Setting a value (writing)

Each scope also has a set block, a stack (action) block that writes a value into the box.

Set Room VariableSet a room variable: change the shared value.
  • Set Room Variable writes the room's shared value.
  • Set Player Variable writes one player's value.

The value you put in is checked against the variable's type. You can't, for example, store text in a number variable. The block won't let you snap the wrong thing in.

Gotcha: there is no "add 1" block

Hideout has no one-step "change variable by 1" block. To bump a number up, you read it, add with a Math block, and set it back:

set room variable score to (room variable score) + 1

What variables remember (and forget)

ScopeOne box or many?Survives the round / reboot?
RoomOne for the whole roomYes, kept forever until you overwrite it
PlayerOne per playerYes, kept per player
Gotcha: room values do not reset on their own

Room and player variables stick around across rounds, reboots, and even republishing your scripts. If you want a fresh score each round, reset it yourself (for example, in a when room starts handler). They never clear automatically.

A quick worked example

Per-player score that starts at 0 for everyone
  1. In the Variables panel, add score with scope Player, type Number. (Number variables default to 0, so every player starts at zero with no setup.)
  2. when player interacts with [coin]set player variable [triggering player] score to (player variable [triggering player] score) + 1.

Each player's score is their own. Player A scoring never touches player B.

Under the hood

The precise rules
  • Variable names are 1 to 64 characters long.
  • A brand-new variable that holds a player or an object starts out as nothing (null), not "the current player". Set it before you rely on it.
  • Changing a variable's type in the panel resets its starting value to that new type's default.
  • The writes a script makes are buffered: held in memory and only saved once the run finishes a step successfully. If a run crashes or runs out of budget, the variable changes it made since its last wait are thrown away. World actions it already did (like moving an object) still stay done, though.
  • Leaving a player set block's owner socket empty is a publish-time error, so the editor stops you before you ever run. But if the socket is filled with something that turns out to be nothing at run time (a player value that's null), that one write is silently skipped.

What's next?