Warning: Script took too long to execute
Slow-script warnings and server stutters almost always come from a loop without a Wait. We explain how to find it and fix it.
The problem
The console warns "Script X took too long to execute" or the server/client stutters (hitches) every so often.
The cause
A loop (`while true` or `CreateThread`) that doesn't yield time to the engine because it lacks a `Wait`, or a heavy operation running every frame.
The solution
Add a `Wait` inside the loop so the engine can breathe:
lua
-- BAD: freezes the thread, causes hitches
CreateThread(function()
while true do
-- checks
end
end)
-- GOOD: yields time each iteration
CreateThread(function()
while true do
Wait(0) -- every frame; raise to 500/1000 if you don't need that precision
-- checks
end
end)Step by step
- 1.Look for `while` and `CreateThread` without a `Wait` inside.
- 2.If you don't need to check every frame, raise the `Wait` (250, 500, 1000 ms).
- 3.Avoid heavy computations or database queries inside fast loops.
- 4.Measure with `resmon` which resource spends the most ms and start with that one.
Related guides
Last updated: 2026-06-17. Crxative-M is not affiliated with Cfx.re or Rockstar Games.
