What is script timeout: exhaustion allowed execution time?

So I was using a while true do loop to rotate “handles” for a shop inventory. Of course this means that all the handles are rotated simultaneously, as I can’t seem to find a way to rotate a specific handle if that viewport frame for the handle was open. Anyways I have a large amount of handles, and a simple loop had resulted in this error.

script timeout: exhaustion allowed execution time

When I opened up the shop, studio literally froze for around 10 seconds. Why is this? Is it because my loop is running too many rotations at once, indefinitely. If your wondering this is that simple line of code.

while true do
			handle.CFrame = handle.CFrame * CFrame.Angles(0.1,1,0)
		end

I was thinking of changing it to a while wait() do loop. On another note, I really don’t want to be running 100 handles at once. Is there any way to have the rotation more smoother and efficient, and not all at once?

For the smooth part of the rotation I was thinking of using renderstepped(client) or heartbeat(server). Additionally I could use RunService as well.

2 Likes

Here you go :slight_smile:

Thanks, this will help. Though, that’s a bit more complicated and I’m not sure as to why it actually happens. Still not sure of how to handle the rotation individually, so it doesn’t all run at once.

Hello, the issue here is that the loop is running constantly, and it isn’t stopping, causing for the script to use up too much memory.

The easy solution to this is either doing:

while wait() do
  -- code
end

or

while true do
   wait()
  --code
end

the wait() is a 0.03 second intervenal which will be almost non-noticable, but it will allow for the script to run! have a nice day!

3 Likes

add a wait on the while loop so it will wait

Ohh, thankyou so much. I had a feeling I overlooked the wait.

but it would run instantly super fast because its only .03 seconds

It does work, 0.03 seconds suffices.

3 Likes

If you found my solution helpful, please, mark it as the solution!

It does work, though how would you handle the rotations?