Chapter 3

Events and the Green Flag

Discover how yellow event blocks like the green flag start your scripts and let sprites react.

How does a Scratch project know when to start? The answer is Events. Event blocks are yellow and they are the blocks that start a script. They are shaped with a rounded bump on top, called a hat block, so nothing can snap above them.

The Green Flag

The most famous event block is when green flag clicked. When you click the green flag above the Stage, every script that starts with this block runs at the same time. This is how most projects begin.

Other Event Blocks

  • when space key pressed — runs when a chosen key is pressed. You can pick space, arrow keys, letters, and more.
  • when this sprite clicked — runs when you click that sprite.
  • when backdrop switches to — runs when the Stage changes to a chosen backdrop.
  • when I receive — runs when a message is broadcast.

Broadcasting Messages

Sprites can talk to each other using broadcast. One sprite uses the broadcast message1 block to send a signal, and any sprite with a when I receive message1 block will react. This is great for making sprites work together, like starting the next part of a story.

Hat Blocks

Because event blocks are hat blocks, they must always sit at the top of a script. You build the rest of your blocks underneath them. A script without a hat block will not run on its own.

Remember

  • Event blocks are yellow and start scripts.
  • when green flag clicked is the usual way to begin a project.
  • Use broadcast and when I receive to make sprites talk to each other.

Stuck on this topic? A verified JomKelas tutor can walk you through it.

Find a verified tutor