Skip to content

5. Messages and Custom Blocks

Two tools let you organize bigger projects: broadcasts send a message every sprite can react to, and My Blocks let you define your own reusable block — the Scratch version of a function.

Broadcasting between sprites (useful for switching rooms in a text adventure):

# In the room-1 sprite
when green flag clicked
broadcast [go to room 2]

# In the room-2 sprite
when I receive [go to room 2]
show

A custom block, made with Make a Block in the My Blocks category:

define greet
say [Hello!] for (2) seconds
wave arm for (1) seconds

when this sprite clicked
greet

Once defined, greet can be dropped into any script, as many times as you want — no retyping the steps inside it.

Try it

Make a custom block called greet that makes your sprite say hello and do something else, then call it from a when this sprite clicked script.

Tip

Reach for a custom block whenever you catch yourself building the same stack of blocks more than once.

Next: Mini Project →