top of page

Variables Blocks

What is variable?

Variable is a reserved memory location to store values. Memory location has a label and a value. The value can be dynamic and can be changed programmatically.

Variables can only hold one value at a time, unlike lists. These values can be either numbers or strings.

How to create your own variable?

The clickable button “make variable” in variables category, allows the user to create new variable.

Scratch does not allow variables to be created by a script as it runs. Instead, variables are created with the "Make a Variable" button

What is the difference between “for all sprite”, “for this sprite only” and “cloud variable”?

When you create your own variable, you will get two options of radio buttons and one checkbox option.

For all sprite:

This is a global variable. Global variables can be read and changed by any sprite, or the Stage. All variables are stored in RAM, and default to the values in the file it originates from. When creating a variable, by default ‘for all sprite is applicable.

For this sprite only:

This is a local variable. Local variable can be created by selecting “for this sprite only” option. These variables can only be changed by their owner but can be read by other sprites. The Stage cannot have local variables.

Cloud variable:

Cloud variables are variables that are stored on the cloud server. In Scratch 3.0, cloud variables only support numerical data, and all are limited to 256 characters, you are allowed 10 cloud variables in a single project.

How to rename the variable?

You can rename the variable in two ways. One you can right click on the variable and select the option “rename”.

Another way – you can programmatically change using any of the 4 blocks.

How to delete the variable?

You can delete in two ways. One you can right click on the variable and delete.

Another way – Use any of the 4 blocks to delete.