That was one of the only solutions I could think of.
Another way of handling this lag is by allocating a table for each model, and when a child is added/removed, update the table with that information. Since you aren’t calling GetChildren() on a model, and the table is allocated before the model has been loaded or etc, you can then use a for loop to delay each destruction of children.
for Index, Child in pairs(AllocatedChildren) do
Child:Destroy()
if Index % 10 == 0 then
wait()
end
end
Yeah it’s been done before using CFrames, To add on there is a community resource for this, the solution is to not actually delete the model but move it far away so Roblox doesn’t actually render it I believe.
I am just making a wild guess, could you try making the parts transparent, also in your loop you could add a good wait time probably to make it better.
Anyways I am just guessing what can be causing it, as there isn’t really any code you have provided in the post.
I don’t believe that it would cause less lag if you moved it away, since I’ve tried that with my image rendering program and it lagged the same.
If you did use :GetChildren(), there would be a stutter before removing the model’s parts, which is why I did my method of the children table.
You could delete a few parts at a time and wait in between. Like this: GetChildren() on the model, Destroy() x amount of those parts, wait(), Destroy() x amount of those parts, wait() and so on until the model is fully deleted. That way its spread out so that it doesn’t lag. Say you have 100 parts, dstroying 10 of them at a time and waiting would be a lot less laggy than destroying all 100 at once.
I hope that helps, I just thought of that and have never tried it so I have no idea if it works well.
EDIT: This is almost the same as what @Winky_y said
The reason that I can’t use a :GetChildren is that the model is deleted on request of a RemoteEvent, and there are models constantly being added and removed from the game. For example, the plate removal remote fires with the argument being the plate to remove, then the script removes it.
Already exploiter proof, please don’t mention the fact that exploiters can also trigger remote events.