9. Variables

Variables are like boxes that can hold things. In Scratch, a variable has a name and can hold a value. Variables are useful for tracking things such as the location of a sprite.

9.1. Mutating variables

The following code blocks changes (mutates) a variable.

_images/00-set-my-variable.png

This code block sets a variable to a specified value.

_images/01-change-my-variable-by-1.png

This code block changes a variable by the specified amount.

9.2. Showing and hiding variables

You may also show and hide variables on the stage.

_images/02-show-variable-myvariable.png

This code block shows a variable.

_images/03-hide-variable-my-variable.png

This code block hides a variable.