# Chapter 9: Variables (Memory & State) > Store changing values—score, lives, speed, and game state—and master proper initialization and scope. Chapter 9: Variables (Memory & State) — Scratch Daizen English Textbook. Store changing values—score, lives, speed, and game state—and master proper initialization and scope. ## Lesson goal & core concept Initialize variables reliably and choose between global ("for all sprites") and local ("for this sprite only") variables. Think of a variable as a labeled box. "set" replaces what is inside; "change" adds or subtracts from what is already there. ## Step-by-step practice Work through these steps in the Scratch editor, predicting each result before clicking the green flag. - Create a score variable and reset it to 0 under the green flag. - Increment score when collecting a star, with a short wait or hide so it counts once. - Use a "state" variable ("title", "playing", "gameover") to control phases. - Use local variables when each clone needs its own HP or speed. **Chapter 9: Variables (Memory & State) — Example** - When green flag clicked - Set (score) to (0) - Set (lives) to (3) Try it: Starts every game cleanly with fresh counters. ## Mini challenge & next steps Swap the values of two variables A and B using a third temporary variable "temp". - [Scratch Learning Textbook Home](/en/textbook/): Return to the full 4-stage curriculum overview. - [Scratch Block Dictionary](/en/dictionary/): Look up any block used in this chapter. Updated: 2026-11-23 Author: [Takamasa Suzuki](https://scratch.gmnavi.jp/about/author/) Japanese Edition: https://scratch.gmnavi.jp/textbook/ch09-variables/ [Scratch Daizen (English)](https://scratch.gmnavi.jp/en/)