Topic Guide

Loops and Repetition

Loops repeat a group of commands. The programmer chooses what repeats, how often, and when it stops.

Why this matters

A game checks for collisions many times each second. A robot keeps reading its distance sensor. Putting that work in a loop makes the repeated rule easy to see and change.

Beyond this topic

A traffic signal repeats a cycle, but it cannot simply flash every light at once. The sequence, timing, and stopping rule are part of the loop.

Math and logic

Repeat count

Run the commands a fixed number of times.

Forever

Keep running them while the project is active.

Repeat until

Check a condition and stop when it becomes true.

Iteration

One trip through the loop.

Small examples

1

Snowball wave

Launch each hazard after a controlled delay.

2

Animation cycle

Repeat costume changes at a readable speed.

3

Robot patrol

Move along the route and check for obstacles each time.

4

Countdown

Subtract one after each timed interval.

Program connections

Where this topic appears.

Active now

Scratch & Game Design

Students author games, animations, simulations, and strange interactive stories while learning how events, rules, and state fit together.

Active now

Robotics

Students write commands, wire simple circuits, read sensors, and trace physical cause and effect through the Sense–Decide–Act loop.

Coming later

Roblox Studio / Lua

A possible later step from visual programming into Lua, 3D objects, events, and larger game rules.

Common mistakes

Accidental forever loop

The program never reaches the blocks beneath it.

A condition that never changes

The repeat-until loop has no way to finish.

Copied blocks

One timing change has to be repaired in twenty places.

No pause

The loop runs so quickly that the result cannot be seen or controlled.

Put the idea to work

Read the Lesson
Scratch & Game Design Guided Project

Attack of the Angry Snowballs

Defend a mug of cocoa from falling snowballs. Each wave gets faster, and winter becomes less reasonable.

  • Loops
  • Randomness
  • Coordinates
  • Collision
See how it works
Robotics Computer Lab Project

Robot Patrol Challenge

Design a repeating patrol that notices an obstacle, tries a response, and checks whether the response worked.

  • Loops
  • Sensors
  • Conditions
  • State
See how it works
Scratch & Game Design Guided Project

The Floor Is Definitely Lava

Build a one-room platform game with a controlled jump, safe platforms, lava, and a clean restart.

  • Sensing
  • Collision
  • Coordinates
  • Variables
See how it works