Ibnovate Scratch Creators
⏱ 60 minLive session

Session 6 — Keep Score with Variables

Duration: 60 min · Format: live online

Session goal: by the end, students can make a variable, show it on the stage, and use set and change so that clicking a target makes the score go up — the first real ingredient of a game with rules.

Soft skill focus — Problem-solving

Today's human skill: Problem-solving. Making a score actually count up — and not get stuck at 1 — means working out which block does which job and fixing it when the number misbehaves.

Before class — prep


Hook

Ask the class (chat or unmute):

Take three answers. Then reveal: "The game keeps your score in a labelled box in its memory. Every time you score, it opens the box, takes out the number, adds one, and puts it back. Today we build that box — it's called a variable — and make our own score go up."


Teach — Make a variable & show it

Share this diagram and read it out:

A score variable stores a number and goes up each time the player scores a point

Explain, slowly, pointing on your shared screen:

Build this together live on your shared screen:

1. Click the Variables (orange-red) category, then click Make a Variable.

2. Type the name score and click OK. (Tell them: pick a name that says what's inside — score, not x.)

3. Look at the palette — new blocks appeared: score, set [score] to 0, change [score] by 1, plus show and hide.

4. Look at the stage — a little score readout appeared in the top-left corner. That's the box showing its number to the player.

Tick the checkbox next to the score block to show or hide it on the stage.

Ask: "What should we call a variable that counts how many lives you have left?" (Answer: something clear like lives — the label should describe what's in the box.)


Teach — set to 0 and change by 1

Explain: two blocks do almost all the work with a score:

Build this together:

1. From Events (yellow), drag out when green flag clicked.

2. From Variables, snap set [score] to 0 under it — the game always starts at zero.

Now click your target sprite (the apple/ball) in the sprite list so you're adding code to it.

3. From Events, drag out when this sprite clicked.

4. From Variables, snap change [score] by 1 under it.

Now you have two little scripts:

when green flag clicked
set [score] to 0
when this sprite clicked
change [score] by 1

Press the green flag (score shows 0), then click the target a few times — watch the number on the stage climb: 1, 2, 3… You just kept score!

⚠ Watch for set vs change: set [score] to 1 does not mean "add one" — it forces the score to 1 no matter how high it was. To count up, use change [score] by 1. Mixing these up is the #1 score bug.

Ask: "Which block resets the score to zero at the start — set or change? Which one adds a point?" (set [score] to 0 resets; change [score] by 1 adds.)


Activity — Build a click-for-points game

Students build their own scoring game. Demo the first steps, then let them go and circulate.

  1. Open a new project at Scratch and Make a Variable called score.
  2. On the stage/background script: when green flag clicked → set [score] to 0.
  3. On the target sprite: when this sprite clicked → change [score] by 1. Press the flag, then click the target — the score should go up.
  4. Make it move so it's a real game: on the target, add when green flag clicked → forever → go to [random position] (from Motion) so it jumps around and you have to chase it with your clicks.
  5. Extra: add a reward — when this sprite clicked → change [score] by 1 → play sound [pop] → say "+1". Or add a second variable called misses.

Circulate and ask: "Show me the block that resets your score. Show me the block that adds a point. What's the difference?"

Debrief: ask 2–3 students to share their screen, press the flag, and rack up a few points live for the class.


Check for understanding

Ask these aloud or in the chat. Answer key (for you):

  1. What is a variable, in your own words? → A labelled box that remembers a number while the program runs; the label is its name and the number inside can change.
  2. What does set [score] to 0 do, and when do we use it? → It puts the exact number 0 in the box, wiping out whatever was there. We use it at the start to reset the score.
  3. You want the score to go UP by one each click. Which block — set or change?change [score] by 1 — it adds to what's already there. set would force it to one fixed number instead.

Wrap-up + homework


Teaching notes

Vocabulary

Term Meaning
Variable A labelled box that remembers a number
Make a Variable The button that creates a new variable and its name
set Put an exact number into the box (replaces what was there)
change by Add an amount to the number already in the box
Stage readout The little box on the stage that shows a variable's number

Resources

Practice set

Extra tasks to explore variables and scoring. Work them easy → hard, at lab time or for homework. Answers follow each arrow.

1. Name it. What do we call a labelled box that remembers a number? → A variable.

2. Colour clue. You want to make a score. Which palette do you open, and what do you click first? → The Variables (orange-red) palette, then Make a Variable.

3. True or false. change [score] by 1 replaces the score with the number 1. → Falsechange by 1 adds one to what's already there. set is the one that replaces.

4. Predict. The score is showing 5. You run set [score] to 0. What does the stage show now? → 0set wipes the box and puts 0 in, so the 5 is gone.

5. Fix it (spot the bug). A student clicks their target ten times but the score stays at 1. Their click script is when this sprite clicked → set [score] to 1. What's wrong? → They used set … to 1, which forces it to 1 every click. Swap it for change [score] by 1 to count up.

6. Make it (harder). Build a game where the green flag resets score to 0, clicking the target adds a point, and reaching 3 points makes it say "Nice!" → Stage: when green flag clicked → set [score] to 0. Target: when this sprite clicked → change [score] by 1 → if <score = 3> then → say "Nice!".

Going deeper (optional)

Optional — for a class that's kept a score and wants to know how far variables go.

Variables hold more than scores. A variable can remember any number the program needs to keep track of — a timer counting down, how many lives are left, the player's speed, the level number. Later, variables can even hold words (like a player's name from an "ask" block, coming in Session 8). The box doesn't care what you keep in it; you decide what the label means.

Why the name matters. Programmers name variables carefully — score, lives, speed — because in a big project you might have ten boxes, and a name like x tells you nothing. A good name is a note-to-self: it says what belongs in the box. This is a habit real developers live by, and starting it now with score instead of a makes every future project easier to read.

Common mistakes & fixes

Next session

Session 7 — The X–Y Grid: students learn how the stage is a grid of x (left–right) and y (up–down) numbers, and use go to x: y: and glide to place and move sprites to exact spots — the maths behind aiming and moving in games.

Ibnovate · Build · Innovate
Type to search · Esc to close
Welcome back
Sign in to continue building.
Accounts are created by Ibnovate — ask your instructor for your login.
🔒