← Years 5–6 Creating Digital Solutions

Set and change variable blocks

A variable block that stores a starting value in score. Use change score by 1 to add to it, or by -1 to take away, so the score counts up or down.

Understanding Set and change variable blocks in Years 5–6 Creating Digital Solutions

What it does: A negative number in the change block subtracts from the variable, so the value counts down. 'set score to 0' replaces whatever was stored with 0. 'change score by 1' would just add one more point. Set the starting value once at the beginning. If it was inside the loop, the score would reset to 0 each time. Set overwrites the value, while change adds to the current value, so only change can keep a running total.

Common mistakes: The change block adds to a variable, so it must say 'by'. It should be 'change score by 1'. The word 'to' belongs in the set block. The set block stores a starting value, so it uses 'to'. It should be 'set score to 0'. The word 'by' belongs in the change block.

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 51–60) 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
Which block puts a starting value into the score variable at the start of a game?
set score to 0change score by 0
Matches
when green flag clicked change score by 1 (no set block first)
↓
The score was never set to 0 at the start, so it keeps the old value from the last game and the count will be wrong. Add set score to 0 first.
Applying
Meanings
Term
set score to 0
Meaning
A variable block that stores a starting value in score. Use change score by 1 to add to it, or by -1 to take away, so the score counts up or down.
Practice
when green flag clicked
Testing
Gaps
score to 0
Check Answer
Spots
2set score to 0
3change score to 1

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

The 'Abyssal Dragon' badge — Deep Sea Legend, 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. Which block puts a starting value into the score variable at the start of a game?
A. set score to 0 ✓
B. change score by 0
'set' stores a value in the variable. It is used at the start so the score begins at a known number like 0.
2. What does 'change score by 1' do when score is 4?
A. Score becomes 1
B. Score becomes 5 ✓
'change' adds to the number already stored. 4 + 1 = 5. Only 'set' would replace the value with 1.
3. Which block makes the score jump back to 0 for a new game?
A. change score by 1
B. set score to 0 ✓
'set score to 0' replaces whatever was stored with 0. 'change score by 1' would just add one more point.
4. A player loses a life. Lives is 3. Which block makes lives go DOWN to 2?
A. change lives by -1 ✓
B. change lives by 1
A negative number takes away. -1 counts down, so 3 becomes 2. Using 1 would count up to 4.
5. Where should 'set score to 0' usually go in a script?
A. Near the start, under the green flag ✓
B. Inside the loop, every time a point is scored
Set the starting value once at the beginning. If it was inside the loop, the score would reset to 0 each time.

Match the Pairs

set score to 0 → Stores the starting value 0 in the score variable, so the game begins with a score of zero.
change score by 1 → Adds 1 to the number already stored in score, so the score counts up.
Counting down: take 1 life away each time the player is hit → change lives by -1
Setting at the start: give lives a starting value of 3 when the game begins → set lives to 3
when green flag clicked change score by 1 (no set block first) → The score was never set to 0 at the start, so it keeps the old value from the last game and the count will be wrong. Add set score to 0 first.
set score to 1 (used to add a point each time a coin is touched) → The set block replaces the score with 1 every time instead of adding to it. Use change score by 1 to count up.

Key Term

set score to 0
A variable block that stores a starting value in score. Use change score by 1 to add to it, or by -1 to take away, so the score counts up or down.

Fill in the Blanks

1. set score to 0 change score by 1
Hint: Type the block word that stores a starting value in the variable.
2. when green flag clicked set score to 0
Hint: Type the starting number for a brand new game.
3. when space key pressed change score by 1
Hint: Type the block word that adds to the variable without resetting it.
4. set lives to 3 change lives by -1
Hint: Type the number that makes the variable count down by one.
5. when this sprite clicked change score by 1
Hint: Type the name of the variable that is being changed.

Spot the Error

Question 1
A when green flag clicked
B set score to 0
C change score to 1
D say score
Line C — The change block adds to a variable, so it must say 'by'. It should be 'change score by 1'. The word 'to' belongs in the set block.
Question 2
A set score by 0
B change score by 1
C change score by 1
D say score
Line A — The set block stores a starting value, so it uses 'to'. It should be 'set score to 0'. The word 'by' belongs in the change block.
Question 3
A when green flag clicked
B change lives by 3
C change lives by -1
D say lives
Line B — At the start, lives needs a starting value, so this line should use a set block: 'set lives to 3'. A change block only adds to what is already stored.
Question 4
A when green flag clicked
B set score to 0
C change score by 1
D change points by 1
E say score
Line D — The program uses a variable called score, but this line changes a different variable called points. It should be 'change score by 1' so the score keeps counting up.
Question 5
A when green flag clicked
B set timer to 10
C change timer by 1
D say timer
Line C — A countdown needs to take away from the timer. Changing by 1 adds, so the timer would count up. It should be 'change timer by -1'.

Student with a class code? Join your class →