Just yesterday my game worked fine. Today, whenever I test the game, it freezes for like 2 minutes and gives a load of “Script timeout: exhausted allowed execution time” errors.
After a bit of searching, it turns out every single wait(number) function in my game is freezing the game and giving that area.
Make sure that the task.wait()/wait() function is inside any while loop/repeat until loop blocks. It’s okay not using wait() on for loops unless they’re used too frequently.
Example:
-- This is what you should do to prevent script exhaustion
while true do
for i, v in pairs(units) do
if i % math.floor(#units/4) then
task.wait()
end
end
task.wait()
end
-- This is what you SHOULDN'T do to prevent script exhaustion
while true do
for i, v in pairs(units) do
task.wait()
end
-- no wait, so this script could get exhausted
end