- Learnt28 min · buttons, a best that lasts, a results card
- Basic25 min · finish the game
- Challenge 1–327 min · a record moment, your own words, a medium button
- Extrabonus · wipe the records, safely
Review — where we got to 5 min
- A
streakgrows on each right answer, andchange [score v] by (streak)makes it pay. - The level, chosen first, sets
minandmax. - The question maker builds
questionandcorrecttogether.
Quick-fire
In the Quiz Show, the green flag set best to 0. What happens to your best score when you close Scratch and open the project tomorrow?
Reveal the answer
Scratch saves every variable’s number inside the project. So tomorrow the best is still there — until you press the flag, which wipes it. Today we stop the flag doing that.
Today’s Topic 3 min
- Easy and Hard buttons:
when this sprite clicked, thenbroadcast [start round v] best easyandbest hard— records the flag never wipes- A results card: an if / else chain, highest score first
(join (words) (join [ You scored ] (score)))— words and numbers in one sentence
Learning outcome
By the end of this lesson you will be able to:
- Start a game from buttons, with a broadcast.
- Keep a best score for each level that survives the green flag.
- Tell the player how they did in words, not just a number.
Learnt — menu, record, card 28 min
1 · A menu with two buttons
Typing “easy” works, but a button is quicker and nobody spells it wrong. You made a Start button in the Quiz Show. Today there are two, and each one means something.
- Add the Button2 sprite. Name it
Easy. - In the Costumes tab, pick the T tool and write Easy on it.
- Right-click the sprite and Duplicate it. Name the copy
Hardand change its word. - Make a variable called
level. - Give each button the three scripts below.
when this sprite clicked
set [level v] to [easy]
broadcast [start round v]
when I receive [start round v]
hide
when I receive [menu v]
show
The Hard button is the same, with hard in its set block. The Wizard hears the message and reads level:
when flag clicked
broadcast [menu v]
when I receive [menu v]
say [Pick Easy or Hard.]
when I receive [start round v]
if <(level) = [easy]> then
say [Easy: numbers 1 to 5.] for (3) seconds
else
say [Hard: numbers 2 to 12.] for (3) seconds
end
broadcast [menu v]
How to use this: Click the green flag, then click Easy or Hard on the stage.
2 · A best score the flag never wipes
In the Quiz Show, the flag set best to 0. So the best only lasted until the next flag. Today’s rule is simple:
| Variable | Set by a script… |
|---|---|
score, streak, lives | at the start of every round |
best easy, best hard | only when a score beats it — never on the flag |
Scratch saves every variable’s number inside the project. So a best that nothing resets is still there tomorrow.
- Make
best easyandbest hard. Good names — notb1andb2. - Drag out
set [best easy v] to (0)on its own. Do not join it to any hat. - Click it once. Do the same for best hard.
- Delete the two loose blocks. The bests now start at 0.
- Save the project.
when flag clicked
set [score v] to (pick random (10) to (40))
say (join [This round: ] (score)) for (2) seconds
if <(score) > (best easy)> then
set [best easy v] to (score)
say [A new best!] for (2) seconds
else
say (join [Best is still ] (best easy)) for (2) seconds
end
How to use this: Click the green flag to start it. Nothing else to press — watch it through, then press the flag again a few times.
One best for each level
20 on hard is harder than 40 on easy. One best for both would be unfair. So the round checks the level first:
when I receive [round over v]
if <(level) = [easy]> then
if <(score) > (best easy)> then
set [best easy v] to (score)
end
else
if <(score) > (best hard)> then
set [best hard v] to (score)
end
end
broadcast [results card v]
3 · A result in words
“You scored 57” means little to a new player. “Great work!” means something straight away. The words depend on the score.
when I receive [results card v]
if <(score) > (99)> then
set [words v] to [Times-table master!]
else
if <(score) > (39)> then
set [words v] to [Great work!]
else
if <(score) > (9)> then
set [words v] to [Good start.]
else
set [words v] to [Keep practising.]
end
end
end
say (join (words) (join [ You scored ] (score))) for (3) seconds
when flag clicked
set [score v] to (3)
broadcast [results card v] and wait
set [score v] to (25)
broadcast [results card v] and wait
set [score v] to (60)
broadcast [results card v] and wait
set [score v] to (130)
broadcast [results card v] and wait
How to use this: Click the green flag to start it. Nothing else to press — watch it through, then use ↺ Reset to run it again.
Why such big numbers? The streak. Twenty right in a row on easy is 1 + 2 + … + 20, which is 210.
Basic — finish the game 25 min
Open last lesson’s game. By the end the Wizard has seven scripts. Test after each step.
Step 1 — the buttons
- Make the Easy and Hard buttons from Learnt 1, with all three scripts each.
- Drag them onto the chalkboard, one above the other.
Step 2 — the flag and the menu
- Pull the ask and the level if / else off the flag script. Keep them to one side.
- The flag script becomes
broadcast [menu v]and nothing else. - Add a
when I receive [menu v]script. It switches to the Chalkboard and says “Pick Easy or Hard.”
Step 3 — start round
- Start a
when I receive [start round v]script. - Put the level if / else under it, testing
(level), not(answer). - Then set score, streak and lives, and broadcast play.
Step 4 — round over
- In the play script, change the last say to
broadcast [round over v]. - Build the round over script from Learnt 2.
- Build the results card script from Learnt 3.
- At the end of the card, say it with the level too, then
broadcast [menu v].
Step 5 — the bests
- Click a loose set-to-0 block once for each best, then delete it.
- Play easy twice and hard once.
- Press the green flag. Both bests must still be there.
when flag clicked
broadcast [menu v]
when I receive [menu v]
switch backdrop to [Chalkboard v]
say [Pick Easy or Hard.]
when I receive [start round v]
say []
if <(level) = [hard]> then
set [min v] to (2)
set [max v] to (12)
else
set [min v] to (1)
set [max v] to (5)
end
set [score v] to (0)
set [streak v] to (0)
set [lives v] to (3)
broadcast [play v]
when I receive [results card v]
switch backdrop to [Spotlight v]
if <(score) > (99)> then
set [words v] to [Times-table master!]
else
if <(score) > (39)> then
set [words v] to [Great work!]
else
if <(score) > (9)> then
set [words v] to [Good start.]
else
set [words v] to [Keep practising.]
end
end
end
say (join (words) (join [ You scored ] (join (score) (join [ on ] (level))))) for (5) seconds
broadcast [menu v]
The play script is last lesson’s, ending in broadcast [round over v]. The question maker and the clock do not change.
How to use this: Click the green flag, then click Easy or Hard on the stage. Type your answer in the box and press Enter for each question.
My best goes back to 0 when I press the flag.
A set [best easy v] to (0) is joined to the flag or to start round. Take it off. Bests are only set when a score beats them.
Hard gives easy numbers.
The start round script still tests (answer). It must test (level) now — nobody typed anything.
Everybody gets “Good start.”
Your card tests the smallest number first. Put the biggest test at the top.
The buttons stay on the board during the round.
Each button needs when I receive [start round v] then hide.
A record moment
Beating a best is a big deal. Make the game say so.
- When a best is beaten, the Wizard says “New best on easy!” or “New best on hard!”.
- It happens before the results card.
- A round that does not beat the best says nothing extra.
Teacher reveal
if <(score) > (best hard)> then
set [best hard v] to (score)
say (join [New best on ] (join (level) [!])) for (2) seconds
end
One say block in each inner if. Joining the level means one sentence serves both.
Your own words
Rewrite the results card in your own words, with more steps.
- At least five different cards.
- Every card still shows the score.
- The tests go from the highest score down.
Teacher note — the bands are a design choice
Ask where their numbers came from. A pupil who has played ten rounds and picked bands from real scores has done game design. Kind words at the bottom matter most — that card is seen the most.
A Medium button
Add a third level, with its own button and its own best.
- A Medium button between Easy and Hard.
- Medium uses numbers from 2 to 9.
- A
best mediumthat only a medium round can change. - The card names the level, whichever it was.
Teacher reveal — three places grow an extra branch
The new button is a duplicate with medium in its set block. Then an if inside the else grows in two scripts: start round (min 2, max 9) and round over:
if <(level) = [easy]> then
if <(score) > (best easy)> then
set [best easy v] to (score)
end
else
if <(level) = [medium]> then
if <(score) > (best medium)> then
set [best medium v] to (score)
end
else
if <(score) > (best hard)> then
set [best hard v] to (score)
end
end
end
The usual miss: the new button works, but round over still files medium scores under hard. Have them watch all three best boxes while testing.
Wipe the records, safely
Sometimes a player wants a fresh start. Let them wipe the bests — but never by accident.
- On the menu, pressing R asks “Type YES to wipe the best scores.”
- Only YES wipes them. Anything else leaves them alone.
- R does nothing during a round.
Teacher reveal
when [r v] key pressed
if <(on menu) = [yes]> then
ask [Type YES to wipe the best scores.] and wait
if <(answer) = [YES]> then
set [best easy v] to (0)
set [best hard v] to (0)
say [Records wiped.] for (2) seconds
else
say [Records kept.] for (2) seconds
end
end
Scratch ignores capitals, so “yes” also wipes. That is fine. The point is that a stray key press never costs anybody their record.
Summary 5 min
The Times-Table Challenge is finished. Over four lessons it learnt to:
- make up its own questions with pick random, join and the green maths blocks;
- run against a clock, with lives, and end by itself;
- reward a streak, change its level, and mix × and +;
- start from a menu, keep a best for each level, and give a result in words.
Today’s big idea: some variables are reset every round, and some are never reset by the flag at all. Choosing which is which is part of designing a game.
- Menu
- The first screen. The player chooses there, then the game starts.
- Best score
- The highest score so far. It only changes when it is beaten.
- Saved value
- The number a variable held when you saved. It comes back when you open the file.
- Results card
- The end screen that tells the player how they did, in words.
Hand in
Save your finished game. If you have a Scratch account, share it and send the link to your teacher. Then play it cold tomorrow: can you follow it with every script window shut?
Next lesson: a new arc — Road Crossing. Lanes of cars, and a hopper that has to get across.