|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)|
|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.
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.
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 forever if <touching (laser v)?> then hide change [score v] by (1) end end
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  seconds stop [all v]
Changing a level
when green flag clicked forever if <touching (goal v)?> then change [level v] by  wait until <not <touching (goal v)?>>
Uses of variables
- Storing changeable information
- Keeping track of time