Document stub.png This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (August 2018)
Document stub.png This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. (August 2019)
Reason: No scripts, not enough examples.
A variable can be used any time a value must be stored, be it a score, name, or option. Variables can also be used to easily create text on the Stage.

Variables are very versatile, with many purposes. Some uses include keeping a score, or saving input, checking options, and printing text. They can also be used to create easily customizable bases.

Lists can be used instead of several variables, or for an indeterminate amount of variables.

Example Uses


A variable can be used to represent a player’s score in games. Most variables are used to maintain scores and lists in cloud games. The variable in this case is usually named “score” or “points”. This is an example of increasing the score when the player hits an alien in a space-themed game:

In the alien sprite:

when green flag clicked
set [score v] to [0]
    if <touching (laser v)?> then
        change [score v] by (1)

The script below congratulates the player if they reach a score of 50 or higher and then stops the project:

when green flag clicked
wait until <(score)>(49)>
say [Congratulations!] for [2] seconds
stop [all v]

Changing a level

Variables can also be used for games that have levels in them. Here is an example script:

when green flag clicked
repeat until <(level) = [5]>
    if <touching (goal v)?> then
    change [level v] by [1]
    wait until <not <touching (goal v)?>>

Uses of variables

  • Platforming
  • Storing changeable information
  • Broadcasting
  • Keeping track of time
  • Scores

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.