Script Timeout: Exhausted allowed execution time

Hello, I’m currently experiencing an error that makes me go insane. I have a map that my game tries to load and when it does so, it errors with “Script Timeout: Exhausted allowed execution time”.
The bug didn’t appear yesterday, which confuses me even more.

There are no loops that infinitly runs, no function that loops itself, so I am very confused on what this could possibly be caused by, but according to the prints I made before the script times out, it’s due to parenting the map into workspace, but I’m not sure why it errors there.

My friend is also experiencing this problem, less frequently than me but still.

Here are some images:
Here is the console and prints I was talking about.


Here’s the code.

Any help is appreciated, thank you.

3 Likes

This happens if you loop without a wait. Try waiting before every iteration

2 Likes

I stated in my post that there are no loops that infinitly runs.

3 Likes

If you think there are no issues with loops you can change the max execution time through your studio settings.

1 Like

Then show us more of your code to better analyse the problem, we don’t know when the function gets ran.

1 Like

I’m wondering why it even errors here in the first place as it didn’t happen yesterday (I didn’t do any modification to the code).

1 Like

If it was me I would see what happens when you change the max execution time. You can set it to -1 and there will be no time limit.

2 Likes

The function gets ran when the player touches a teleporter.

1 Like

I have this in my bookmarks and this solution always works for me (make sure you call MaybeYield() where this error occurs)

2 Likes

I’m gonna try it, I’ll post the result one done.

2 Likes

Try adding a debounce to the touched function.

There is already one.

charaaaa

Then i have no idea what the problem is, maybe just a bug in studio or something.

1 Like

Call MaybeYield() before you map.Parent=workspace

I think the map is big and it yields script for very long time which makes it execution timeout

2 Likes

I’m not sure how i can implement those functions in my script since they aren’t loops, and I also tried putting a task.wait() before and after map.Parent = workspace.

what if you put task.wait() before rf.mapdebris:ClearAllChildren()

I tried doing so, it obviously removed the error but what I’m trying to figure out is why it errors there (on other terms, why it lags this much).

I actually removed the rf.mapdebris:ClearAllChildren() line because i realized that the folder wasn’t even being used anywhere in the script.

Except loops without wait time, this error can also be caused by too much thread or too much things that run at same time.

The output say it is comming from your 3 functions (loadmap, teleport, touched), so something in one of these function is doing too much things at same time… keep in mind a for_ do is also a loop, in case you got one or multiple for loop.

2 Likes

I’m gonna try and add a task.wait() on most of the lines and see which one makes me lag the most, and no, there are no for loops.