Script timeout while doing a large Model:MoveTo()

I’m dynamically constructing a level at the start of my game and that involves copying and moving around some large models. Recently I started getting this error.

ServerScriptService.Main:70: Script timeout: exhausted allowed execution time  -  Server - Main:408

Is there any way I can stop Model:MoveTo() from counting against my script time? There’s no easy way for me to break this model up into smaller models.

2 Likes

I tried wrapping my Model:MoveTo() in a delay() and the script stopped timing out.

That’s OK but not great, as now I have to think about concurrency.

2 Likes

Have you tried using PivotTo() instead?

:PivotTo and :MoveTo have 2 different behaviours. :MoveTo accounts for objects at the specified Vector3 position and moves the model position upwards until the model doesn’t collide with anything while :PivotTo just moves the model to specified CFrame without accounting for other BaseParts.

How are you moving your model? Moving the primary part should not be script intensive. Is this an animation? Tween service?

And how large is large? I’ve accidentally grabbed a city block and studio didn’t think very hard about dropping it off miles away. This is either absolutely massive, or you have a script error.

OP never said that they were using MoveTo() for its collision functionality. This is still a valid option to try if they aren’t using it for that.

I didn’t know about :PivotTo.

Right now I am using the collision detection functionality of :MoveTo, but I know the bounds of everything so I could probably use PivotTo with a little work, if that is like setting the CFrame of the Model’s primary part.

2 Likes

Yep, unless you edited the pivot of the primary part.

I’m just setting the Cframe of the primary part and that is much faster, so that’s the solution this time.

If I did need the functionality of MoveTo() then I would be totally stuck here. Seems like Engine time and Script time should be counted differently or the timeout should be configurable.

2 Likes