Reading Time: 12 mins

Want your Scratch sprites to talk to each other? Broadcast messages are the secret! This comprehensive guide shows you exactly how to use broadcast messages in Scratch to create coordinated actions, build complex games, and make your projects truly interactive.
A broadcast message in Scratch is a communication tool that lets sprites and the stage send signals to each other. Think of it like a walkie-talkie system β when one sprite βbroadcastsβ a message, any sprite listening for that message can respond and take action.
Real-world analogy: Imagine a teacher announcing βLunch time!β to the classroom. All students hear the announcement and respond by putting away their work and lining up. Thatβs exactly how broadcast messages work in Scratch!
Why broadcast messages matter:
Broadcast messages work through a sender-receiver system:
The Sender (Broadcasting):
broadcast [message name]
This sprite sends out a signal that any other sprite can hear.
The Receiver (Listening):
when I receive [message name]
This sprite waits for the signal and responds when it hears it.
Key principle: The message name must match exactly (case-sensitive) for the communication to work.
broadcast [message1] block into your code areaPro tip: Use descriptive names like βstart_level_2β instead of generic names like βmessage1β. This makes your code easier to understand later.
when I receive [message name] block to the code areaExample code:
When green flag clicked
wait (2) seconds
broadcast [game start]
---
When I receive [game start]
say "Let's play!" for (2) seconds
go to x: (0) y: (0)
show
Problem: You want all sprites to get ready when the game begins.
Solution:
// Stage code
When green flag clicked
set [score] to [0]
switch backdrop to [main menu]
broadcast [init game]
---
// Player sprite
When I receive [init game]
go to x: (0) y: (-100)
show
set [lives] to [3]
---
// Enemy sprite
When I receive [init game]
hide
wait (3) seconds
show
Problem: When the player reaches the exit, everything needs to change.
Solution:
// Door sprite
When this sprite clicked
if <touching [player]?> then
broadcast [next level]
end
---
// Stage
When I receive [next level]
switch backdrop to [level 2]
broadcast [reset positions]
---
// All sprites
When I receive [reset positions]
go to x: (starting x) y: (starting y)
Problem: Multiple things need to happen when the player loses.
Solution:
// Player sprite
When I receive [hit by enemy]
change [lives] by (-1)
if <[lives] < [1]> then
broadcast [game over]
end
---
// Stage
When I receive [game over]
stop all sounds
play sound [game over music]
switch backdrop to [game over screen]
---
// UI sprite
When I receive [game over]
show
say "Game Over! Click to restart" for (5) seconds
What it does: Pauses the sender until all receivers finish their actions.
When to use it: When you need actions to happen in a specific order.
Example:
// Main controller
broadcast [spawn enemies] and wait
broadcast [start music]
---
// Enemy spawner
When I receive [spawn enemies]
repeat (10)
create clone of [myself]
wait (0.5) seconds
end
The music wonβt start until all 10 enemies have spawned.
Creating a cutscene:
// Director sprite
When green flag clicked
broadcast [scene 1]
wait (3) seconds
broadcast [scene 2]
wait (3) seconds
broadcast [scene 3]
broadcast [game start]
---
// Character sprites respond to each scene
When I receive [scene 1]
say "Welcome to the adventure!" for (3) seconds
When I receive [scene 2]
glide (2) secs to x: (100) y: (0)
say "Let's explore!" for (3) seconds
Creating a quiz game:
// Question sprite
When this sprite clicked
if <answer = [correct answer]> then
broadcast [correct answer]
else
broadcast [wrong answer]
end
---
// Score keeper
When I receive [correct answer]
change [score] by (10)
broadcast [next question]
When I receive [wrong answer]
change [lives] by (-1)
broadcast [next question]
---
// Question controller
When I receive [next question]
change [question number] by (1)
if <[question number] > [10]> then
broadcast [quiz complete]
else
broadcast [show next question]
end
Broadcast Messages:
Variables:
Best practice: Use both together!
// Use variables to track state
set [game state] to [playing]
// Use broadcasts to trigger responses
broadcast [game started]
Broadcast messages: Global β all sprites hear them Clone events: Local β only affects individual clones
Example:
// Broadcast affects ALL enemies
broadcast [enemies attack]
When I receive [enemies attack]
// Every enemy sprite responds
// Clone event affects ONE clone
When I start as a clone
// Only this specific clone runs this code
Sometimes you need to clean up unused messages.
Steps to delete a broadcast message:
broadcast or when I receive blockβ οΈ Warning: Deleting a message will break any code using it. Make sure no sprites are listening for that message before deleting.
How to check if a message is in use:
Bad:
broadcast [msg1]
broadcast [m]
broadcast [2]
Good:
broadcast [player_died]
broadcast [level_complete]
broadcast [enemy_spawned]
Game state messages:
Level messages:
Character messages:
Add comments to explain what each message does:
// Broadcast [game_start]
// Initializes all sprites and begins gameplay
// Receivers: player, enemies, UI, background music
broadcast [game_start]
Problem:
// Sprite A
When I receive [message A]
broadcast [message B]
// Sprite B
When I receive [message B]
broadcast [message A]
This creates an infinite loop and will freeze your project!
Solution: Use variables to track state:
When I receive [message A]
if <not [already processing]> then
set [already processing] to [true]
broadcast [message B]
end
Inefficient:
repeat (100)
broadcast [update position]
end
Better:
repeat (100)
// Do calculations
end
broadcast [positions updated]
Problem:
broadcast [Start Game]
When I receive [start game] // Won't work - different capitalization!
Fix: Message names are case-sensitive. Use exact spelling:
broadcast [Start Game]
When I receive [Start Game] // Now it works!
Problem:
broadcast [load level]
broadcast [start timer] // Timer starts before level loads!
Fix:
broadcast [load level] and wait
broadcast [start timer] // Now timer starts after level loads
Problem: Broadcasting a message but no sprites are listening for it.
Fix: Always create the receiver code:
// Sender
broadcast [show hint]
// Receiver (don't forget this!)
When I receive [show hint]
show
say "Press SPACE to jump" for (3) seconds
Problem:
forever
broadcast [update score] // Broadcasts hundreds of times per second!
end
Fix:
forever
if <[score] > [previous score]> then
broadcast [update score]
set [previous score] to [score]
end
end
Letβs build a simple multi-level platformer using broadcast messages:
Stage Code:
When green flag clicked
ββ set [level] to [1]
ββ set [score] to [0]
ββ broadcast [init game]
When I receive [init game]
ββ switch backdrop to [level 1]
ββ broadcast [start level]
When I receive [level complete]
ββ change [level] by (1)
ββ wait (2) seconds
ββ switch backdrop to (join [level ] [level])
ββ broadcast [start level]
When I receive [game over]
ββ stop all sounds
ββ switch backdrop to [game over screen]
ββ stop [all]
Player Sprite:
When I receive [start level]
ββ go to x: (-200) y: (-100)
ββ show
ββ broadcast [enable controls]
When I receive [enable controls]
ββ forever
ββ // Movement code here
When I receive [player hit]
ββ play sound [ouch]
ββ change [lives] by (-1)
ββ if <[lives] < [1]> then
ββ broadcast [game over]
Goal Sprite:
When I receive [start level]
ββ go to x: (200) y: (100)
ββ show
forever
ββ if <touching [player]?> then
ββ play sound [success]
ββ broadcast [level complete]
Enemy Sprite:
When I receive [start level]
ββ go to x: (0) y: (-80)
ββ show
forever
ββ if <touching [player]?> then
ββ broadcast [player hit]
This structure uses broadcast messages to coordinate all game elements cleanly and efficiently.
Goal: Create a 3-question quiz using broadcasts.
Messages needed:
Challenge: Make the quiz only advance when the correct answer is given.
Goal: Create a 5-scene story using timed broadcasts.
Messages needed:
Challenge: Add character dialogue that changes in each scene.
Goal: Create a boss that goes through 3 phases.
Messages needed:
Challenge: Broadcast phase changes based on boss health percentage.
Essential broadcasts:
Essential broadcasts:
Essential broadcasts:
Essential broadcasts:
Possible causes:
when I receive)Debugging steps:
// Add temporary feedback
When I receive [your message]
say "I received the message!" for (2) seconds
// Your other code
Solution: Use broadcast and wait:
broadcast [first action] and wait
broadcast [second action] and wait
broadcast [third action]
Solution: Consolidate related broadcasts:
Before:
broadcast [update score]
broadcast [update lives]
broadcast [update timer]
After:
broadcast [update UI]
When I receive [update UI]
// Update score, lives, and timer all at once
Use variables in broadcast names:
set [current level] to [3]
broadcast (join [load_level_] [current level])
// Broadcasts "load_level_3"
Managing complex game states:
// State controller
When I receive [enter menu state]
ββ set [game state] to [menu]
ββ broadcast [show menu]
When I receive [enter play state]
ββ set [game state] to [playing]
ββ broadcast [start gameplay]
When I receive [enter pause state]
ββ set [game state] to [paused]
ββ broadcast [show pause screen]
For complex sequencing:
// Add to queue
add [cutscene_1] to [event queue]
add [cutscene_2] to [event queue]
add [start_game] to [event queue]
// Process queue
When green flag clicked
forever
if <(length of [event queue]) > [0]> then
set [current event] to (item (1) of [event queue])
broadcast [current event] and wait
delete (1) of [event queue]
end
end
// Broadcast triggers the sequence
When I receive [enemy attack pattern]
ββ execute attack pattern :: custom
// Custom block handles the details
define execute attack pattern
move (10) steps
turn (15) degrees
wait (0.1) seconds
// etc.
Essential points to remember:
The power of broadcasts: When used correctly, broadcast messages transform your Scratch projects from simple animations into sophisticated, interactive experiences. Theyβre the difference between sprites acting independently and sprites working together as a coordinated system.
Now that you understand how to use broadcast messages in Scratch, youβre ready to build truly impressive projects!
Apply what youβve learned:
Continue learning with ItsMyBot:
At ItsMyBot, we turn screen time into skill time through personalized, industry-level courses that adapt to your childβs pace. Our tutorials like this one are just the beginningβimagine what your child could create with dedicated mentorship and structured learning.
π Ready to take coding seriously? Explore our courses designed for young creators aged 5-15.
π‘ Want more free tutorials? Visit our blog for step-by-step guides on robotics, coding, and game development.
π¨βπ©βπ§βπ¦ Parents: Track your childβs progress and stay involved every step of the way with our transparent reporting system.
Drag the broadcast [message] block from the Events category, click the dropdown, select βNew message,β type a descriptive name, and place it where you want the message sent. Any sprite with a matching when I receive [message] block will respond.
Broadcast messages coordinate actions across multiple sprites and the stage. Theyβre used for starting games, changing levels, triggering animations, managing game states, and creating any situation where multiple elements need to respond to one event.
Click the dropdown on any broadcast block, find the message you want to remove, right-click it, and select βDelete message.β Warning: this will break any code using that message, so verify itβs not in use first.
broadcast sends a message and immediately continues to the next block. broadcast and wait sends the message, pauses until ALL receivers finish their code, then continues. Use βand waitβ when you need specific timing or sequencing.
Thereβs no official limit, but for organization, try to keep it under 20-30 messages per project. Use descriptive names and group related messages by category (game_start, game_pause, etc.) for better code management.
No, broadcast messages are globalβall sprites hear them. However, you can add conditional logic in the receiver to make specific sprites respond differently:
When I receive [player attack]
if <[my name] = [Enemy1]> then
// Only this enemy responds
end
Add temporary feedback in the receiver code:
When I receive [your message]
say "Message received!" for (2) seconds
If the sprite says the message, the broadcast is working. If not, check spelling, capitalization, and that the receiver code exists.
Have you built something cool using broadcast messages? Weβd love to see it!
Connect with the ItsMyBot community:
Remember: Every expert coder started with one broadcast message, one sprite, one project. Keep building, keep learning, and keep creating!
About ItsMyBot
ItsMyBot turns screen time into skill time with personalized, industry-level courses that adapt to your childβs pace and potential. We provide international collaboration opportunities, keep parents informed every step of the way, and equip kids with technical know-how that opens doors to high-paying, future-ready careers.
From Scratch basics to advanced robotics, we help your child master skills that matter.