Session 16 — Score & Loops
Duration: 60 min · Format: live online · Ages: 8–11
Session goal: by the end, students can create a score variable, use a forever loop to keep the game alive, and use broadcasts so sprites can talk to each other.
Before class — prep (5 min)
- Open Scratch and click Create — you'll screen-share and live-build.
- Have a starter idea ready: a "catch the apple" game — an apple sprite that keeps falling with a forever loop, and a Score that goes up when you press the space bar (we'll make it react to catching next session).
- Load the project from Session 15 if you want to build on it, or start fresh — either works.
- Ask students to open Scratch with their Session 15 project (or a blank one) ready.
Agenda
| Time | Segment |
|---|---|
| 0:00 | Hook — how does a game keep score? (5 min) |
| 0:05 | Teach — variables hold a number (12 min) |
| 0:17 | Teach — forever loops and broadcasts (13 min) |
| 0:30 | Activity — build a score + a falling sprite (20 min) |
| 0:50 | Check for understanding (7 min) |
| 0:57 | Wrap-up + homework (3 min) |
0:00 · Hook (5 min)
Ask the class and take a few answers (chat or unmute):
- "In your favourite game, where does the score show up, and what makes it go up?"
- "The game keeps checking things over and over without stopping. How do you think it does that?"
- "How does one part of a game tell another part 'hey, the player scored!'?"
Let them guess, then reveal: today you learn three superpowers — a variable to remember the score, a loop to keep the game running forever, and a broadcast so your sprites can send each other messages.
0:05 · Teach — Variables hold a number (12 min)
Explain, on your shared Scratch screen:
- A variable is a box that remembers a number for you. A score is just a number that keeps changing.
- Go to the Variables section (orange), click Make a Variable, and name it Score. A
Scorebox appears on the stage.
Demo in Scratch:
- Drag
set [Score] to 0and snap it underwhen green flag clicked. Explain: every game starts the score at zero. - Drag
change [Score] by 1underwhen [space] key pressed. Press space a few times — the score climbs.
⚠ Watch for the mix-up between
setandchange:set Score to 0replaces the number;change Score by 1adds to it. If students useset Score to 1every press, the score gets stuck at 1. Show this on purpose so they see the difference.
Ask: "At the start of a game, should we set Score to 0 or change Score by 0? Why?" (Answer: set to 0 — we want it to become zero, not just add nothing.)
0:17 · Teach — Forever loops and broadcasts (13 min)
Explain: a game never stops checking things — it does the same job over and over. That's a loop. The forever block (yellow, Control) repeats everything inside it, endlessly.
Share this diagram so students can picture the game loop — when the flag is clicked, a forever loop keeps moving sprites, checking collisions, and updating the score:
Demo in Scratch, building live:
- Add a second sprite (an apple or ball). Give it
when green flag clicked→forever→ inside:change y by -5. - Click the green flag. The apple falls, and falls, and falls — the loop keeps running. Explain: without
forever, it would move once and stop. - Add
if on edge, bounceor reset withset y to 150inside the loop so it keeps coming back (show either — we'll polish next session).
Now broadcasts — how sprites talk to each other:
- Explain: a broadcast is like shouting a message across the room. One sprite broadcasts, any sprite can listen with
when I receive. - Demo: on the cat, add
when [space] key pressed→broadcast [caught]. On the apple, addwhen I receive [caught]→play sound [Pop]andgo to x: 0 y: 150(jump back to the top). - Press space — the message fires, the apple pops and resets.
Key point to land: a variable remembers, a loop repeats, and a broadcast lets sprites send messages to each other.
Ask the class: "If I take the
change y by -5out of the forever loop and just leave it on its own, how many times does the apple move?" (Answer: once.)
0:30 · Activity (20 min)
Students build their own "catch" starter. Screen-share your version as a reference.
Build this, step by step:
- Make a variable called Score (Variables → Make a Variable).
- On the main sprite:
when green flag clicked→set [Score] to 0. - Add a second sprite (apple, ball, star).
- On the second sprite:
when green flag clicked→forever→change y by -5. - Inside the same forever loop, add
if y < -150 then→set y to 150(so it loops back to the top). Ifif/thenis new, just useset y to 150after a few seconds for now. - On the main sprite:
when [space] key pressed→change [Score] by 1andbroadcast [caught]. - On the second sprite:
when I receive [caught]→go to x: 0 y: 150andplay sound [Pop]. - Click the green flag and test: the apple falls, space adds to the score and resets the apple.
Circulate for:
- A score that jumps straight to 1 and sticks — they used set Score to 1 instead of change Score by 1.
- A forever loop that "freezes" the editor — usually there's a forever with nothing that lets the screen update; adding a wait 0.1 seconds inside helps, or they simply need to click the flag to start it.
- Broadcasts that don't fire — the message name in broadcast and when I receive must match exactly (check the dropdown).
Encourage: ask students to change the falling speed (
change y by -5→-8) and notice the game gets harder.
0:50 · Check for understanding (7 min)
Ask these aloud or drop them in the chat. Answer key (for you):
- What is a variable, and what would you use one for in a game? → A box that remembers a number; use it for a score, a timer, lives, or a level number.
- What does a
foreverloop do? → It repeats the blocks inside it endlessly, so the game keeps checking or moving without stopping. - How can one sprite tell another sprite that something happened? → With a broadcast — one sprite
broadcasts a message, another runswhen I receivethat message.
0:57 · Wrap-up + homework (3 min)
- Ask one student to explain the difference between
setandchangein their own words. - Homework — Level Up the Score: make the score go up by a different amount for a special action (for example,
change Score by 5on a rare key), or add a second variable likeLives. Bring it to Session 17.
Teaching notes
- Correct this misconception: "a
foreverloop is broken because it never ends." That's the point — games are meant to keep running. What students usually want is a loop that repeats but still lets other things happen; a tinywaitinside keeps it smooth. - Fast finishers (extension): have them add a timer using a second variable —
set Time to 30at the start, then a separate loop that doeswait 1 seconds→change Time by -1. Challenge: whenTimehits 0,broadcast [game over]and have a sprite say "Time's up!" This quietly previews the win/lose logic of Session 17. - Low-tech fallback: if a student can't run Scratch, have them tally a score on paper while a partner "plays," and draw arrows showing a message being passed from one character to another — acting out what a broadcast does.
Practice set
Assign in class or as homework. Answers are for you, after the arrow.
- Make a variable called Score and set it to 0 when the green flag is clicked. → Variables → Make a Variable → name it
Score; thenwhen green flag clicked→set [Score] to 0. - Make the score go up by 1 every time you press the space bar. →
when [space] key pressed→change [Score] by 1. (Use change, not set.) - Make a sprite fall down the screen forever. →
when green flag clicked→forever→change y by -5. - When the falling sprite reaches the bottom, send it back to the top. → Inside the loop:
if y < -150 then→set y to 150(orgo to x: 0 y: 150). - Make one sprite send a message and another sprite react to it. → Sprite A:
broadcast [caught]. Sprite B:when I receive [caught]→ do something (play a sound, hide, reset position). - Add a second variable called Lives, start it at 3, and lower it by 1 on a key press. → Make
Lives;set [Lives] to 3at start;when [key] pressed→change [Lives] by -1.
Going deeper (optional)
- Show the variable live on stage. Tick the checkbox next to a variable to show it, and use the display options (right-click the box) to make it a slider or a large readout. Ask students where a real game shows its score, then place theirs in a matching spot. This connects the code to how games actually look.
- Why broadcasts beat "just doing it in one script." Explain that in a real game, catching an apple has to do several things at once — add score, play a sound, reset the apple, maybe speed things up. A single broadcast can wake up many sprites at the same time, each doing its own job. Have them add a second
when I receive [caught]on a different sprite (say, a cheering sprite) to feel this power.
Common mistakes & fixes
- Mistake: using
set Score to 1on every press, so the score never grows past 1. → Fix: switch tochange Score by 1;setreplaces,changeadds. - Mistake: forgetting to
set Score to 0at the start, so scores from the last play carry over. → Fix: always start withwhen green flag clicked→set [Score] to 0. - Mistake: the broadcast name and the "when I receive" name don't match, so nothing happens. → Fix: pick the same message from both dropdowns; if unsure, make a new message with a clear name like
caught. - Mistake: a
foreverloop with nowaitmakes the sprite move too fast or the editor feel stuck. → Fix: add a smallwait 0.1 secondsinside the loop, or lower the movement number. - Mistake: putting the score-change inside the forever loop by accident, so it counts up thousands of times per second. → Fix: keep
change Score by 1under the key-press event, not inside the falling loop.
Vocabulary
| Term | Meaning |
|---|---|
| Variable | A box that remembers a number, like a score |
| Set | Put an exact value into a variable (replaces it) |
| Change | Add to (or subtract from) a variable |
| Loop | Blocks that repeat; forever repeats endlessly |
| Broadcast | A message one sprite sends and others can receive |
Resources
- Scratch — free, in your browser, no install (main tool).
- Scratch Ideas: Make It Fly / catch games — starter guides that use variables and loops.
- Scratch Wiki: Variables — friendly reference on what variables do.
- Scratch Wiki: Broadcast — how sprites send and receive messages.
Next session
Session 17 — Levels & Challenge: students add if/then decisions, detect when sprites are touching, and build real win and lose conditions to make the game harder.