“Variables” are used to store information. You can use it to store a number, a word, or a sentence.
To create a new variable, click on “Make a Variable”. The new variable can be “For all sprites” (every sprite can read and set the value) or “For this sprite only” (other sprites will not see this variable).
To set the value of a variable, you can use the “set variable to” block.
To change the value of a variable, you can use the “change variable by” block. If your variable starts as “0”, running a “change variable by 1” block will change it to “1”. Running it again will change it to “2”.
“Show variable” and “Hide variable” is to display or hide the variable on the screen. You can also click on the checkbox next to the variable to show and hide it.
Variables don’t reset at the end of a program, so be sure to set it to its starting value when your program start (eg. Set the “Score” variable to zero).
To use the value of a variable, drag the rounded variable into any rounded white space inside a block. In the above example, “my variable” was placed inside the “say” block. The above code will make the sprite say “42” when ran.
When setting a variable multiple times, only the last “set” will have effect. In the above script, the sprite will say “1”.
When changing a variable, it will add on to the previous value. In the above script, the sprite will say “44”. This is the result of 42 + 1 + 1.