Make a Variable

Variables are made (declared) in the "Global Variables" TAB. If you don't have that TAB then use the "+" to add it to your project. You don't have to declare these Global Variables in your script (js file) like normal JavaScript, however, you may declare variables in your script file as per normal JavaScript if you wish. Do not declare the same variable twice because it won't run.

Variable Types:

  • String: "word" or "text" eg 'clicked'
  • Number: mathematical number eg 24
  • Boolean: value can be either "true" or "false" but this is NOT a "string" variable.
  • Array: same as Scratch3 "List"
  • Timer

Set Variable

my_variable = 0

Change Variable

my_variable = my_variable + 1

Variable Example

The Variable 'forever_condition' is declared as Type 'Boolean'. It's intial value can be set as below.

forever_condition = true