How can I remove a model without causing lag?

Valid solution. I’ve tried adding waits of over .1 second between parts (purely experimental) and I’ve still received a constant amount of lag, but dragging out the removal in a different form may just yield the same result of one long lag spike.

You can use a for loop for this
But if that still causes lag, i think theres no possbile way to remove models without lag.

Please read the thread before replying :smiley:

Just a thought, maybe you could union some parts that cannot be accessed by the player? This would reduce the part count and would make it lag less… hopefully.

1 Like

You can remove its children, this will mean you can control how long it takes to remove children. You could even break it into chunks this way and remove a set amount of parts at a time.

You can also put it in and out of server storage which also helps to reduce lag as the parts arent rendered in. (out for loading, in for destroying)
When loading them in anchor and non-collision them so they don’t strain collisions or physics and then set them back to normal once it has fully loaded. This will also prevent parts moving while loading and causing issues.

By the way, is there any lines of code under the :Destroy()?

If there is, it might be wise to use Debris service to prevent the lag yielding the script.

I can give you some advice on how to destroy the model in a different way. Maybe you can use it to destroy the model without lags.
Try removing the Parent your model using the script, and then destroy the model using Destroy().
I suggest a script that is located inside the model.

local Model = script.Parent 

wait(5) -- I added wait() so I can see how the model is destroyed.

Model.Parent = nil -- Deleting the Parent from the model .
Model:Destroy() -- Destroying the model.

It is possible that deleting Parent from the model will not cause you lags.

[EDIT]
If you have a super extreme situation that nothing helps, could you leave a link to the model or attach it as a file? This will help to solve the problem faster.

If you intend to make it get removed on the client in 1 go, but instant removal isn’t a problem on the server, you can go this way on a LocalScript, while pausing gameplay to reserve more resources to the process and end it quicker.

For the server, I suggest making a lot of children models inside the big one and deleting them one by one.
GetChildren() on 1 model containing 60 models is better than doing the same function on 3000 individual parts.

I believe that CFrame is one of the most inexpensive properties to change. So going off something that I’ve seen in community resources (forgot the module name), you could set the CFrame of the model with SetPrimaryPartCFrame to somewhere really far, and then gradually remove it if need be.

1 Like

Try parenting the model to nil