← Years 5–6 Creating Digital Solutions

Debugging a visual program

Finding the block that causes a wrong result in a program and fixing it, such as a block in the wrong order or a wrong condition.

Understanding Debugging a visual program in Years 5–6 Creating Digital Solutions

What it does: The blocks are stacked in the wrong order. Debugging means finding this and swapping the blocks so move comes first. Blocks run from top to bottom. Swap the two say blocks so 'Hello' is on top. Running one script at a time helps you find the exact script that has the bug. Showing the variable lets you see its value change (or not change) as the program runs. The condition checks the wrong number. Change score = 1 to score = 10. A wrong condition or event block can stop a script from running when you expect. Always test again. This checks that the fix worked and nothing else broke.

Common mistakes: Changing the score by 0 means it never goes up, so the sprite says 0. Showing the score variable helps you spot this. It should be change score by 1. The blocks are in the wrong order. The sprite is hidden before it speaks, so you cannot see it say anything. Line 2 should be show.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 61–74) and word search (Modules 41–74).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Your sprite says 'Goodbye' before it says 'Hello', but you wanted 'Hello' first. What is the bug?
The blocks are in the wrong orderThe sprite is broken and must be deleted
Matches
when green flag clicked, say Go! , set score to 0, move 10 steps (the score never resets before the game starts)
↓
The blocks are in the wrong order. Set score to 0 should come first so the game starts fresh.
Applying
Meanings
Term
debugging
Meaning
Finding the block that causes a wrong result in a program and fixing it, such as a block in the wrong order or a wrong condition.
Practice
when green flag clicked
Testing
Gaps
score to 0
Check Answer
Spots
3repeat 3
4 change score by 0

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Moose' badge — Tundra Champion, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Your sprite says 'Goodbye' before it says 'Hello', but you wanted 'Hello' first. What is the bug?
A. The sprite is broken and must be deleted
B. The blocks are in the wrong order ✓
Blocks run from top to bottom. Swap the two say blocks so 'Hello' is on top.
2. Your program has three scripts and something goes wrong. What is a smart way to find the bug?
A. Run one script at a time to see which one causes the problem ✓
B. Delete all the scripts and start again
Running one script at a time helps you find the exact script that has the bug.
3. Your score variable should go up by 1, but it shows 0 all the time. How can you check what is happening?
A. Show the variable on the stage and watch its value ✓
B. Guess and change random blocks
Showing the variable lets you see its value change (or not change) as the program runs.
4. Your game should say 'You win!' when score = 10, but it says it when score = 1. Which kind of bug is this?
A. A wrong condition ✓
B. A wrong block order
The condition checks the wrong number. Change score = 1 to score = 10.
5. What does debugging mean?
A. Making the sprite look nicer with new costumes
B. Finding the block that causes a wrong result and fixing it ✓
Debugging is about finding and fixing the cause of a wrong result.

Match the Pairs

Run one script at a time → Test a single script on its own so you can tell which script is causing the wrong result
Show variable score → Display the value of the variable on the stage so you can check if it changes the way you expect
A wrong block order bug: the sprite should say 'Ready!' after it moves, but it says it before → say Ready! for 2 seconds, then move 50 steps
A wrong condition bug: the sprite should only celebrate when the score is more than 10, but it celebrates at 3 → if score < 10 then say You win!
when green flag clicked, say Go! , set score to 0, move 10 steps (the score never resets before the game starts) → The blocks are in the wrong order. Set score to 0 should come first so the game starts fresh.
repeat until lives = 10 (the game never ends because lives starts at 3 and goes down) → The condition is wrong. The loop should repeat until lives = 0, so it can actually stop.

Key Term

debugging
Finding the block that causes a wrong result in a program and fixing it, such as a block in the wrong order or a wrong condition.

Fill in the Blanks

1. set score to 0 change score by 1 say score for 2 seconds
Hint: Type the block name that must come first so the variable starts at zero. Wrong block order is a common bug.
2. show variable score change score by 1 say score for 2 seconds
Hint: Type the name of the variable whose value you want to watch on the stage while you debug.
3. if score > 10 then say You win! end
Hint: Type the comparison symbol so the message only shows when the score is more than ten. A wrong condition is a bug.
4. when green flag clicked stop other scripts in sprite
Hint: Type the word for the scripts that are not this one, so you can test one script at a time.
5. repeat until lives = 0 change lives by -1 end
Hint: Type the number that makes lives go down each time round, so the loop can finish and the bug is fixed.

Spot the Error

Question 1
A when green flag clicked
B set score to 0
C repeat 3
D change score by 0
E say score
Line D — Changing the score by 0 means it never goes up, so the sprite says 0. Showing the score variable helps you spot this. It should be change score by 1.
Question 2
A when green flag clicked
B hide
C say Ready! for 2 seconds
D hide
Line B — The blocks are in the wrong order. The sprite is hidden before it speaks, so you cannot see it say anything. Line 2 should be show.
Question 3
A when green flag clicked
B ask Enter your score
C if answer < 50 then
D say You pass!
Line C — The condition is wrong. A score of 80 would not pass, but a score of 10 would. It should be if answer > 50 then.
Question 4
A when green flag clicked
B set lives to 3
C hide variable lives
D change lives by -1
Line C — Hiding the variable means you cannot watch its value change while you debug. It should be show variable lives.
Question 5
A when left arrow key pressed
B move 10 steps
C say Moving right
Line A — When you run this script on its own, the right arrow key does nothing. The wrong key is used in the event block. It should be when right arrow key pressed.

Student with a class code? Join your class →