Learning Goals 3 min
By the end of this lesson you will be able to:
- Drag a set [score v] to (0) block and explain that it puts a fresh number into the box.
- Drag a change [score v] by (1) block and watch the watcher count up live on the Stage.
- Toggle the watcher on and off from inside a script using show variable and hide variable.
Warm-Up 7 min
Last lesson you made a variable called score and placed its watcher on the Stage — Arc 1/4 done. The number sat there frozen at 0. Today, four new orange blocks finally let you move it: set, change, show, and hide.
Quick-fire puzzle
Nurul builds this stack. The cat already has a variable called score from yesterday. Predict what the watcher reads after one click of the flag.
when flag clicked
set [score v] to (7)
Reveal the answer
The orange watcher on the Stage jumps from 0 straight to 7. The block set [score v] to (7) tells Scratch: "Empty the score box. Put the number 7 inside it. Done." Watcher updates instantly.
This is one of the most useful blocks in all of Scratch. Every game uses it at the very start to reset the score back to zero before play begins.
New Concept — four orange action blocks 15 min
Yesterday the variable was a box that only displayed a number. Today, four new orange blocks let you reach into the box and change what's inside. Think of them like the buttons on a kitchen weighing scale: one tares the scale to zero, one adds weight, one turns the display on, one turns the display off.
| Block | Category | What it does |
|---|---|---|
| set [score v] to (0) | Variables (orange) | Erases whatever was in the box and puts a brand-new number in. Used at the start of every game to "reset to zero". |
| change [score v] by (1) | Variables (orange) | Adds the number in the round socket to whatever's already in the box. change by (1) = counter goes up by one. |
| show variable [score v] | Variables (orange) | Makes the watcher visible on the Stage. Same effect as ticking the box in the panel — but from inside a script. |
| hide variable [score v] | Variables (orange) | Hides the watcher on the Stage. Useful for title screens or "secret" variables the player shouldn't see. |
"set" empties the box. "change" adds to it.
This is the single most important idea in this lesson. The two blocks look similar — same orange colour, same drop-down, same round number socket — but they do very different things.
- set [score v] to (5) — score is now 5, no matter what was there before.
- change [score v] by (5) — score is now old score + 5. If it was 3, it becomes 8. If it was 100, it becomes 105.
Use set when you want a known value (usually at the start). Use change when you want to add or subtract from the current value (during play).
Negative numbers work too
The round socket of change accepts any number, including negatives. change [score v] by (-1) means "subtract 1" — useful for taking away a life or losing a point.
What the watcher does live
Every time set or change runs, the orange watcher on the Stage updates the displayed number immediately. Click the flag → the watcher number jumps. The watcher is a window into the box, always showing the current value.
Why it matters
These four blocks are the heartbeat of every game. set starts the round. change moves the score during play. show and hide decide whether the player sees what's going on. Master these four, and you can build a scoreboard for any game in the world.
Worked Example — count up to 10 in one click 15 min
Open Scratch. You should still have the score variable from last lesson — if not, make it again from the orange Variables category. The watcher should be visible on the Stage, reading 0.
Step 1 — Drag the hat
From the yellow Events category, drag when ⚑ clicked into the Script Area.
Step 2 — Reset the score
From the orange Variables category, drag set [score v] to ( ) under the hat. Click the round socket and type 0. The drop-down should already say score — if you have more variables, click the arrow and pick score.
Step 3 — Add 5 to the score
Drag change [score v] by ( ) under the set block. Type 5 in the socket. The drop-down should say score.
Step 4 — Add another 5
Drag a second change [score v] by ( ) block underneath the first. Type 5 in this one too.
Step 5 — Say the final value
From the purple Looks category, drag say [Hello!] for (2) seconds beneath the second change block. Now drop the round (score) reporter (from the orange panel, top of the list) into the [Hello!] socket. The block becomes say (score) for (2) seconds.
Step 6 — Click the green flag
Watch carefully. The flow:
- Hat block fires.
- Watcher jumps to
0(from the set block). - Watcher jumps to
5(first change). - Watcher jumps to
10(second change). - The cat says 10 for 2 seconds.
All this happens so fast you barely see the 0 or the 5 — but the watcher does land on each value momentarily. The cat ends up saying 10, which is the final value of score.
What changed: last lesson the cat could only say 0 because no block ever changed the variable. This lesson, the same say-the-score script speaks 10 — because two change blocks updated the box.
Your finished stack
when flag clicked
set [score v] to (0)
change [score v] by (5)
change [score v] by (5)
say (score) for (2) seconds
Try It Yourself — three small builds 12 min
Goal: Reset the score and read it. Build this stack. The cat should say 0.
when flag clicked
set [score v] to (0)
say (score) for (2) seconds
Think: Even if the watcher was showing 99 before you clicked, the set block wipes it back to 0 in an instant. Then the cat reads the new value.
Goal: Count down with negative numbers. Start the score at 10, then take away 3, then take away 4. Predict the final value before you click.
when flag clicked
set [score v] to (10)
change [score v] by (-3)
change [score v] by (-4)
say (score) for (2) seconds
Think: 10 minus 3 is 7, minus 4 more is 3. The cat says 3. Negative numbers in the change block are the same as subtraction.
Goal: Hide the watcher during play, then reveal it dramatically at the end. Build this stack. (Wait blocks need wait (1) seconds from the orange Control category.)
when flag clicked
hide variable [score v]
set [score v] to (0)
change [score v] by (5)
change [score v] by (5)
wait (2) seconds
show variable [score v]
Think: The watcher vanishes the moment the flag is clicked. The score still climbs to 10 — secretly, behind the scenes. Two seconds later, the watcher pops back into view, already showing the final 10. Great for a quiz reveal.
Mini-Challenge — five-second score climb 5 min
"Watch the score climb from 0 to 5 slowly"
Build a single script that resets the score to 0, then adds 1 to the score every second for five seconds. The watcher should tick up: 0 → 1 → 2 → 3 → 4 → 5, one second at a time. (You'll need wait (1) seconds from the orange Control category — same one you used in SCR-L01-18.)
It works if:
- The watcher starts at
0the moment the flag is clicked. - The watcher visibly jumps up by 1 every second.
- The final reading is
5. - The stack uses ≤ 8 blocks — no repeat needed.
Reveal one valid solution
Alternate change and wait blocks five times. With a leading set and a flag hat, that's 8 blocks total — right at the cap.
when flag clicked
set [score v] to (0)
wait (1) seconds
change [score v] by (1)
wait (1) seconds
change [score v] by (1)
wait (1) seconds
change [score v] by (1)
This stack is 8 blocks long. To go all the way to 5, you'd need a tidier tool — that tool is repeat (5). We saw it back in SCR-L01-19. In the next lesson SCR-L01-42, we'll combine change [score v] by (1) with a click event for a tiny taste of a real catch game.
Recap 2 min
Today you met the four action blocks of the Variables category. set empties the box and puts in a fresh value. change adds (or subtracts, with a minus number) to whatever was there. show variable and hide variable control whether the orange watcher is visible on the Stage. The watcher updates live the instant any block changes the box.
- set
- Replaces the current value of the variable with a brand-new number. set [score v] to (0) means "make score zero, no matter what it was".
- change by
- Adds the number in the socket to whatever's already in the box. change [score v] by (1) is the classic "increment by one".
- show variable / hide variable
- Two orange blocks that show or hide the watcher on the Stage. Same as ticking / unticking the box in the panel — but from inside a script.
- watcher
- The small orange label on the Stage that displays a variable's live value. Updates instantly as the variable changes.
Homework 1 min
The water glass tracker. Make a variable called glassesOfWater. Build a script that resets it to 0 at the start, then changes it by +1 three times, then has the cat say the final value. Predict the number out loud before you click the flag, then check.
- Build the 6-block script (hat + set + three changes + say).
- Predict the final value, write it on paper.
- Click the flag and confirm.
- Screenshot your Script Area.
Bring back next class:
- Your screenshot.
- Your prediction (on paper) compared to what actually happened.
- Your written answer: "What would the cat say if you replaced one of the
change by (1)blocks withchange by (-1)?"
Heads up for next class: SCR-L01-42 wires the change block to a when this sprite clicked hat — a tiny taste of a real catch game. Click the cat, score goes up by one. Click again, up by one more.