Ibnovate Scratch Creators
⏱ 60 minLive session

Session 5 — If–Then Decisions

Duration: 60 min · Format: live online

What you'll learn: by the end, you can drop a Sensing block into an if <> then block to ask a yes/no question, and build a sprite that makes a decision — if it's touching the edge it bounces, otherwise it keeps moving.

Soft skill focus — Critical thinking

Today you'll also grow Critical thinking. An if–then block is pure reasoning: you have to decide exactly what yes/no question to ask and what should happen when the answer is true or false.

What you'll need


Hook

Play "only if…" for one minute. Act out each rule:

Notice: sometimes you do the action, sometimes you don't — it depends on whether the rule is true for you. Today you teach your sprite to do that same thing — do something only if a question is true. In code we call it an if–then decision.


Teach — The if–then block & Sensing questions

Look at this diagram and read it left to right:

An if-then decision: if the sprite is touching the edge then it bounces, otherwise it keeps moving

Here's how it works:

Meet three Sensing questions — each one is a diamond block that answers yes or no:

Build this:

1. From Control (orange), drag out if <> then.

2. From Sensing (cyan), drag touching [edge]? and drop it into the diamond hole. Watch it snap into the < > shape.

3. From Looks (purple), snap say [Ouch!] for 1 seconds inside the mouth.

Now your script reads:

if <touching [edge]?> then
  say "Ouch!" for 1 seconds

Drag the sprite so it touches the edge, run it, and it says "Ouch!" Drag it to the middle, run again — nothing happens, because the answer is now no.

Watch out for the empty diamond: an if <> then with nothing in the diamond can never be true, so the inside blocks never run. Always fill the < > with a Sensing (or Operators) question first.

Which colour block gives you the question? Which block does the action? (Question = Sensing/cyan; action = whatever you snap inside, here Looks/purple.)


Teach — if–then–else: two paths

Sometimes you want one thing if yes, and a different thing if no. That's the if <> then … else block — also in Control (orange). It has two mouths: the top runs when the answer is yes, the bottom (else) runs when the answer is no.

Build this:

1. Start a fresh script with when green flag clicked (Events, yellow).

2. Add a forever loop (Control, orange) so the sprite keeps checking — you met forever in Session 4.

3. Inside forever, add move 10 steps (Motion, blue).

4. Under it, add if <> then … else. Drop touching [edge]? into the diamond.

5. In the top mouth (yes): turn ↻ 180 degrees — spin around.

6. In the else mouth (no): leave it empty for now, or add say [zooming!].

Now your script reads:

when green flag clicked
forever
  move 10 steps
  if <touching [edge]?> then
    turn cw 180 degrees
  else
    say "zooming!"

Press the green flag. The sprite zooms across, and the moment it touches the edge it turns around and heads back — then keeps zooming. It's making a decision every single loop.

When the sprite is in the middle of the stage, which mouth runs — the top or the else? (The else — because it's not touching the edge yet.)


Activity — Build a sprite that reacts

Now you build your own reacting sprite.

  1. Open a new project at Scratch.
  2. Build the bouncing script: when green flag clicked → forever → move 10 steps → if <touching [edge]?> then → turn ↻ 180 degrees. Press the green flag — the sprite should ping-pong across the stage.
  3. Add a key reaction: inside the same forever, add a second if <key [space] pressed?> then → say "Boing!". Now it talks back when you press space.
  4. Try else: swap one if for an if … else and make the sprite do something different for no — like next costume when it's not touching the edge.
  5. Extra: use if <mouse down?> then → go to [mouse-pointer] so the sprite jumps to your cursor while you hold the button.

Ask yourself: what's the question in your diamond? What runs when the answer is no?


Check yourself

Try these — the answers are right after each arrow so you can check:

  1. What does the if <> then block do? → It runs the blocks inside it only when the question in the diamond is true (yes); if it's false, Scratch skips them.
  2. Where do the yes/no questions like touching [edge]? come from? → From Sensing (cyan) — they're the diamond-shaped blocks that fit the < > hole.
  3. What's the difference between if … then and if … then … else? → Plain if runs its blocks only on yes and does nothing on no. if … else has two paths: the top runs on yes, the else part runs on no.

Wrap-up


Tips & extra challenges

Vocabulary

Term Meaning
Condition The yes/no question a decision is based on
if–then A block that runs its inside blocks only when the condition is true
else The second path — runs when the condition is false
Sensing block A cyan block that asks about the world (touching, key, mouse)
Boolean A value that is only ever true or false (the diamond shape)

Resources

Practice set

Practise on your own — extra tasks to explore decisions and Sensing. Work them easy → hard. Answers follow each arrow.

1. Colour clue. You want a yes/no question like "am I touching the mouse-pointer?" Which colour block do you look for? → Cyan — Sensing.

2. True or false. A sprite is sitting in the middle of the stage. Is touching [edge]? true or false right now? → False — it's not touching the edge, so an if using it would be skipped.

3. Fix it (spot the bug). An if <> then → say "Hi!" never says anything, even though the block is snapped in fine. What's wrong? → The diamond is empty — there's no question, so it can never be true. Drop a Sensing block into the < >.

4. Predict. The script is forever → if <key [space] pressed?> then → next costume. What happens when you hold the space bar? → The sprite flips through its costumes over and over (animates) for as long as space is held; when you let go, it stops.

5. Make it (build task). Build a script so that when you click and hold the mouse, the sprite says "You clicked me!" → forever → if <mouse down?> then → say "You clicked me!".

6. Two paths (harder). Make a sprite that moves, and turns around at the edge but changes colour everywhere else.when green flag clicked → forever → move 10 steps → if <touching [edge]?> then → turn cw 180 degrees → else → change color effect by 5. The else runs on every loop where it's not at the edge.

Going deeper (optional)

Optional — for when you've built a reacting sprite and want to know why decisions matter.

Every game is just decisions. Every video game you've ever played is thousands of if blocks running very fast: if the player touches a coin, add a point; if health is zero, game over; if the down arrow is pressed, crouch. The diamond questions are the game's senses, and the if blocks are its brain. Once you see this, you start spotting "that's an if–then!" in games you play — which is exactly the programmer's habit of mind.

The diamond shape is a promise. Notice that Sensing and Operators blocks are pointy diamonds, and the if hole is the same pointy shape — so only a true/false block will fit. Scratch is using shape to teach a rule: a decision needs a yes/no question, not a number or a word. That true-or-false idea has a real name programmers use everywhere — a Boolean.

Common mistakes & fixes

If it's not working, check here:

What's next

Session 6 — Keep Score with Variables: students make a variable — a labelled box that remembers a number — and use set and change to keep score, so clicking a target makes the score go up on the stage.

Ibnovate · Build · Innovate
Type to search · Esc to close
Welcome back
Sign in to continue building.
Accounts are created by Ibnovate — ask your instructor for your login.
🔒