Script timeout: exhausted allowed execution timein Roblox Luau: what it means and how to fix it

What it means

The script ran for too long without pausing, so Roblox stopped it. While a script runs without a wait, nothing else in the game can run.

The smallest script that triggers it

Triggers the errorline 2: error here
local count = 0
while true do
  count = count + 1
end

The fix

Fixedline 4: the fix
local count = 0
while true do
  count = count + 1
  task.wait(1)
end

task.wait hands control back to the engine on every pass, so the loop can run for as long as the game does.

Common causes

  1. A while true do loop with no task.wait inside it.
  2. A loop whose exit condition never becomes true.
  3. A very large for loop, or nested loops, doing all their work in a single frame.

Practice this until it sticks

A Deep Dive on loops and task wait: 5-minute lessons, each with a quiz. What you miss comes back in the next module. One Deep Dive a day is free. No card.