Alternative to wait()?

Hey, I’m currently writing a script to insert in a model into my workspace from my replicated storage.

For the sake of simplification, say I have an array of 1000 baseparts that I am inserting into my workspace one by one. This ends up lagging the server so I decided to add a “wait()” inside the array’s insertion loop. This did solve the lag dilemma but it takes a ridiculous amount of time to load the parts in.

A solution I’ve come up with is to “wait()” on a 50 part insertion increment but I was wondering if there was a more efficient way to “load” all the parts.

Any advice is helpful, thanks.

1 Like

Try rendering it on the client using RenderStepped? An obvious issue is it won’t replicate over to other clients nor the server. Possibly look into PartCache. I can’t think of a way getting around the wait times without having to sacrifice performance.

If you wanna try, I haven’t tested this out yet, but try checking if there are clones of various parts and only load 1 part in and clone that part to other clone’s location.

2 Likes
game:GetService("RunService").Heartbeat:Wait()
6 Likes

No lag with optimal loading times. Thank you very much!