← Back to course
easy ✦ 50 Studs

Wait and Exhaustion

Why a loop without wait() crashes the engine, and how wait() paces it.

Sometimes you want a loop that runs forever on purpose: a heartbeat, a spinning part, a timer. You write that with while true do, because true never turns false, so the loop just keeps going.

But here’s the catch that surprises everyone the first time. A forever loop with no pause runs millions of times per second. Roblox notices a script hogging everything and shuts it down to protect the game. That shutdown is called loop exhaustion, and the error reads something like “script exhausted allowed execution time.” It sounds dramatic, but the fix is one tiny line.

That fix is wait(). It pauses the loop for a number of seconds, which gives the engine room to breathe and, conveniently, lets you actually see things happen.

while true do
  print("Still running...")
  wait(2)
end

wait(2) pauses two seconds. wait(0.5) pauses half a second. wait() with nothing inside pauses for the smallest possible tick. The rule to burn into memory: a forever loop needs a wait() inside it, every time, no exceptions.

Now make it yours: write a while true do loop that prints “tick” once per second. Then change the timing to twice per second and feel the difference.

script.Parent
no color yet
Output
Click Run to see your output.