emily.haney
emily.haney 3d ago • 0 views

Scratch Loops: When to Use 'Forever' vs 'Repeat'

Hey everyone! 👋 I'm working on my Scratch project and I keep getting stuck on loops. Like, when do I use 'forever' and when do I use 'repeat'? It seems like they do similar things but also different things? 🤯 I always get confused and my sprites end up doing weird stuff. Can someone give me a clear breakdown?
💻 Computer Science & Technology
🪄

🚀 Can't Find Your Exact Topic?

Let our AI Worksheet Generator create custom study notes, online quizzes, and printable PDFs in seconds. 100% Free!

✨ Generate Custom Content

1 Answers

✅ Best Answer
User Avatar
Dante_Alighieri Mar 11, 2026

📚 Mastering Scratch Loops: Forever vs. Repeat Explained

Understanding when to use the 'forever' loop versus the 'repeat' loop is fundamental to creating dynamic and interactive projects in Scratch. Both are control blocks that execute a sequence of commands, but they operate with distinct timing and termination conditions.

♾️ The 'Forever' Loop: Continuous Action

The 'forever' loop is designed for tasks that need to run continuously throughout the execution of a script or until the program is explicitly stopped. Once started, it will never end on its own.

  • 🎯 Purpose: Ideal for ongoing processes like game main loops, character movement controls, background music, or constant sensing.
  • ⚡️ Execution: Commands inside a 'forever' loop will execute repeatedly, one after another, without any pause or specific end condition built into the loop itself.
  • ⚠️ Stopping: It stops only when the green flag is clicked again (restarting the script), the stop button is pressed, or the script receives a 'stop all' message.
  • 🔄 Common Use: Keeping a sprite following the mouse pointer, playing a continuous sound, or checking for collisions in a game.

🔢 The 'Repeat' Loop: Controlled Iteration

The 'repeat' loop executes a set of commands a specific, predetermined number of times. It's perfect for actions that need to occur a finite number of iterations.

  • Purpose: Great for animations, drawing shapes, performing calculations a set number of times, or making a sprite move a certain distance in steps.
  • Execution: You specify the exact number of times the blocks inside the loop should run. Once that count is reached, the loop terminates, and the script continues with any blocks placed after the 'repeat' loop.
  • ⚙️ Customization: The number of repetitions can be a fixed number, a variable, or the result of an arithmetic operation.
  • 🚶 Examples: Making a sprite walk 10 steps, drawing a square (repeating 4 times for the sides), or making a sound effect play a few times.

📊 Side-by-Side Comparison: Forever vs. Repeat

Feature'Forever' Loop'Repeat' Loop
Control FlowRuns indefinitely until stopped externally.Runs a specified number of times, then stops.
TerminationNo inherent end condition; stops by external event (stop button, 'stop all' block).Ends automatically after completing the set number of iterations.
Use CasesGame main loops, continuous sensing, background music, constant movement.Animations, drawing shapes, timed actions, specific movements.
Iteration CountInfinite (or until stopped).Pre-defined number of times (e.g., 'repeat 10').
Script ContinuationBlocks after 'forever' will never run (unless the 'forever' loop is in a separate script that stops).Blocks after 'repeat' run once the loop completes.

💡 Key Takeaways for Smart Looping

  • 🧠 Choose 'Forever' when you need something to happen constantly in the background or as the main control flow for your game that never stops on its own.
  • Opt for 'Repeat' when you know exactly how many times an action needs to occur, like drawing a polygon or making a character blink a few times.
  • 🛠️ Pro Tip: You can combine these! For example, a 'forever' loop might contain an 'if' block that, when triggered, executes a 'repeat' loop for a special animation.
  • 🚀 Think Before You Loop: Always consider if your action has a definite end. If yes, 'repeat' is likely your friend. If not, 'forever' is the way to go.

Join the discussion

Please log in to post your answer.

Log In

Earn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! 🚀