If you do any of the following it creates a noticeable lag spike:
Setting a clone’s parent to the workspace
Using :Destroy() on literally anything
Using Debris:AddItem() on literally anything
This is a serious issue, as I am making a game where bosses are constantly cloning and destroying projectiles you have to avoid. I’m trying to avoid having to cache clones as much as possible, so if you have any other solutions let me know.
Uh, cache would be a life saver here.
You’re just adding more work into the Garbage collector and the game itself, which can cause performance issues.
For one, GC is cleaning memory up from the destroyed instances / unused data.
And second, the game will be slower when you’re just constantly creating new Instances.
The cache helps you to avoid initializing the projectiles once again, and just re-using an old projectile when the game asks for another one, or making a new one if the cache ever runs out of them.
Try reusing projectiles from a pool instead of constantly creating and destroying them. optimizing your code and avoiding unnecessary computations can also help improve performance.