Learning Goals 3 min
By the end of this lesson you will be able to:
- Explain what a hat block is and why every script needs one on top.
- Drag when ⚑ clicked from the Events category onto the Script Area.
- Snap a say [Hello!] for (2) seconds block under it and watch the cat speak when the green flag is clicked.
Warm-Up 7 min
You have used when ⚑ clicked in every lesson since SCR-L01-01. Today we slow down and ask: why is this yellow block always at the top? This matters right now — our dance show needs a reliable start cue before we add any moves.
Quick-fire puzzle
Wei Jie dragged just one Motion block into the Script Area, with no hat block. He clicked the green flag. What happened to the cat?
move (50) steps
Reveal the answer
Nothing happened. The cat did not move at all. The block was sitting in the Script Area, but Scratch had no idea when to run it. A script without a hat block is like a recipe with no "start cooking when…" line — the chef never begins.
(Tip: if you double-click a lone block, Scratch runs it once on the spot. But clicking the green flag does nothing — only blocks under a flag-hat react to the flag.)
New Concept — hat blocks and the green flag 15 min
Think of a hat block as a starting whistle. A scout troop is standing in a field, ready to march. They will not move until the leader blows the whistle. The whistle says "go!" — the marching is everything after. The green flag is the whistle. The hat block is the scout listening for it.
The block we are learning today
| Block | Category | What it does |
|---|---|---|
| when ⚑ clicked | Events (yellow) | Waits, doing nothing, until the green flag above the Stage is clicked. Then it runs every block snapped underneath, top to bottom. |
The hat shape — why it matters
Every block in Scratch has a shape. The shape tells you where the block is allowed to go. A hat block has a rounded top — like an old-fashioned bowler hat. That rounded top means nothing can sit on top of me. Hats live at the top of a script. Always.
when flag clicked
move (10) steps
Event-driven — a fancy word made simple
Scratch runs scripts when events happen. An event is something that occurs at a moment in time. The green flag being clicked is an event. A key being pressed is an event. The sprite being clicked is an event. The hat block tells Scratch which event your script is waiting for.
For now we have only learned one hat: when ⚑ clicked. In SCR-L01-16 and SCR-L01-17 you will meet two more.
Why it matters
Every Scratch project — every game, every animation, every story — begins with at least one hat block. Without a hat, your blocks are LEGO bricks sitting in a box. Add a hat and the bricks become a working toy. The hat connects your script to the world outside it.
Worked Example — make the cat say hello on the flag click 15 min
Open Scratch. We will build a 2-block script: click the green flag and the cat will say "Hello!" for two seconds.
Step 1 — Open the Events category
In the Blocks Panel (far left), scroll the round category icons until you see the yellow one labelled Events. Click it. The panel fills with yellow blocks.
Step 2 — Drag the flag-hat
Grab when ⚑ clicked. Drag it into the empty Script Area. Drop anywhere. It now sits there, waiting.
when flag clicked
Step 3 — Open the Looks category
In the Blocks Panel, click the purple dot labelled Looks. The panel now shows purple blocks.
Step 4 — Drag the say block
Grab say [Hello!] for (2) seconds. Drag it just below the yellow hat. When you see a faint white highlight, let go. The two blocks snap together.
when flag clicked
say [Hello!] for (2) seconds
Step 5 — Click the green flag
Above the Stage, click the green flag. A white speech bubble pops up next to the cat: "Hello!" It stays for two seconds, then disappears. Click the flag again — same thing.
Step 6 — Edit the message
Click on the word Hello! inside the say block. Erase it. Type Selamat pagi! ("Good morning!" in Malay). Click the green flag. The cat now greets you in Bahasa.
What changed: earlier lessons used the flag-hat without explaining it. Today you finally know why the yellow block is always on top — it is the event-listener that connects your script to the green flag.
The full assembled stack (your reference)
when flag clicked
say [Selamat pagi!] for (2) seconds
Try It Yourself — three small builds 12 min
Goal: Make the cat say a different greeting. Change the say text to Apa khabar? ("How are you?" in Malay) and run it.
when flag clicked
say [Apa khabar?] for (2) seconds
Think: The hat block does not care what is below it. Swap the message, the script still starts on the flag click.
Goal: Have the cat say something and then move. Add a move (50) steps block under the say block.
when flag clicked
say [Here I go!] for (2) seconds
move (50) steps
Think: The blocks run top to bottom. Speech bubble first, then the move. Order matters.
Goal: Build two separate stacks under two flag-hats. When the flag is clicked, both run at once.
when flag clicked
say [Hello from Penang!] for (2) seconds
when flag clicked
move (100) steps
Think: Two hat blocks, two independent scripts. The green flag triggers both at the same instant. Try it — the cat moves and talks together.
Mini-Challenge — greet, glide, greet again 5 min
"Aisyah's Cat says hi from both sides"
Using only blocks from today and earlier (motion + the flag-hat + the say block), build a single script that does this with one click of the green flag:
- The cat says Hello from the left! for 2 seconds.
- The cat glides 2 seconds across the Stage from left to right.
- The cat says Hello from the right! for 2 seconds.
It works if:
- One green flag click runs the whole thing.
- The cat starts on the left side of the Stage and ends on the right.
- You used the flag-hat exactly once.
Reveal one valid solution
Before clicking the flag, set the cat's x to -200 in the Sprite Properties panel. Then build this stack:
when flag clicked
say [Hello from the left!] for (2) seconds
glide (2) secs to x: (200) y: (0)
say [Hello from the right!] for (2) seconds
Four blocks. One hat. The cat greets, glides, greets again. Total: about 6 seconds.
Recap 2 min
Today you learnt the formal name for the yellow block you have been using since lesson one. when ⚑ clicked is a hat block — it has a rounded top, sits on top of every script, and waits for the green flag event. Without a hat, blocks are just bricks in a box. Add a hat and the bricks become a running script.
- Hat block
- A block with a rounded top. It must sit at the top of a script. It listens for one specific event.
- Event
- Something that happens at a moment in time — like the green flag being clicked or a key being pressed.
- when ⚑ clicked (block)
- The Events hat block that waits for the green flag click, then runs the blocks below it.
- Script
- A stack of blocks starting with one hat block. Each script is independent and runs on its own.
Homework 1 min
Three greetings, one click. Build a script that uses one when ⚑ clicked hat, then three say-blocks in a row, with three different Malaysian greetings.
- Open Scratch.
- Drag when ⚑ clicked into the Script Area.
- Snap three say [...] for (2) seconds blocks below it.
- Change the three messages to: Selamat pagi!, Apa khabar?, Jumpa lagi!
- Click the green flag and watch the cat speak each line.
Bring back next class:
- A screenshot of your 4-block script.
- Your written answer: "What would happen if you removed the hat block from the top? Why?"
Heads up for next class: SCR-L01-16 meets a brand-new hat block — when [space v] key pressed. You will make the cat react to a key on the keyboard, not just the green flag.