Scratch loop debugging

Why is a Scratch repeat until loop not stopping?

A repeat until block checks its condition between passes. Debug the condition and the value that should make it true before changing the whole project.

AI-generated photo of a fictional Indonesian coding teacher helping two children test a loop.

Describe the stop condition in plain language

Repeat until keeps running the blocks inside while its condition is false. When the condition becomes true, the script continues with the block below the loop. If the condition is already true when the loop begins, the inside may run zero times.

Ask the child to finish this sentence: “The loop should stop when...” A useful answer is observable, such as “the counter reaches 5” or “the sprite touches the edge.” “When the game is done” is too broad to test.

The opening photograph is AI-generated. The fictional Indonesian teacher and children are not our tutors or clients, and the screen does not show a real school project.

Build a tiny counter test

Create a new variable called count. Set count to 0. Inside repeat until count is greater than or equal to 5, change count by 1 and wait 0.2 seconds. After the loop, say “finished” for one second. Show the variable on the stage so every change is visible.

Predict the displayed sequence before pressing the green flag: 0, 1, 2, 3, 4, 5, then the message. If the small example works, compare it with the original project one block at a time. Keep a separate copy so a test can be undone.

Match the symptom to the first inspection

SymptomInspect firstSmall test
Loop never stopsThe watched value never changesShow the variable and add a short wait
Loop misses the targetEquality test is skipped by a larger stepUse a boundary such as greater than or equal to
Loop runs zero timesCondition is true before entryDisplay the starting value
Project appears frozenLoop body gives the screen no visible pauseAdd a brief wait while debugging
These are starting hypotheses for a test copy, not a diagnosis of an unseen project.

Prefer a boundary when the value can jump

AI-generated photo of a fictional Indonesian coding teacher and child modelling a loop with counters.

This generated photograph illustrates repetition. It is not a real tutor, client, lesson or software screenshot.

Suppose count changes by 2 from a starting value of 0. It visits 0, 2, 4 and 6. A condition that waits for count = 5 never becomes true. If the intended rule is to stop at or after five, count greater than or equal to 5 expresses the boundary more accurately.

Equality is still correct when the project truly requires one exact state and the code guarantees that state can occur. The debugging question is whether the changing value can pass the target.

Separate a finite repeat from a condition-controlled loop

Use repeat 10 when the number of passes is known in advance. Use repeat until when the number depends on a condition that may become true at different times. Choosing the block that matches the rule makes the script easier to explain and test.

Keep the loop body small during diagnosis. Temporarily replace complex movement, sound and scoring with one visible variable change. Restore one behaviour at a time after the stopping condition works twice in the same repeatable test.

Route wider coding support to the owner page

For continuing help with Scratch and programming habits, the established coding tutoring page owns the service intent. This guide stays with one loop behaviour and does not replace a tutor-matching page.

Families considering face-to-face lessons around Berawa can use the Berawa tutoring page for practical arrangements. If the problem involves the starting score, use the separate Scratch score reset guide.

Frequently asked questions

Does repeat until check before or after the first pass?

Scratch checks the condition before running the blocks inside. If the condition is already true, the loop body can run zero times.

Why does count = 5 sometimes fail?

The value may jump over 5, for example from 4 to 6. If the rule is to stop at or beyond the boundary, test count greater than or equal to 5.

Related

Message us on WhatsApp: +62 858 6969 6869 · info@privatetutoringbali.com · We reply within one working day.

Sources and further reading

Published by Private Tutoring Bali. Sources and corrections.

By subject

By curriculum and stage

Learning support

For companies

Tutoring areas: South and coast

Tutoring areas: Centre and east

Tutoring areas: North and far east

Private Tutoring Bali