What’s the least laggy method to spawn in a special attack? So basically I’m making a game, and when the boss uses his special attack, 10 objects fly out of him and damage the players.
Does creating the parts inside the script cause the least amount of lag? (The objects consist of multiple parts)
I was thinking I could clone the objects from a saved location like the ServerStorage and then inserting them into the workspace, but is that more lag?
If there’s only 10 objects I doubt it will lag.
You can put a wait() though between each object spawned to prevent a possible lag spike from several objects being spawned at one time.
Cloning the objects into workspace won’t be more lag. If you’re concerned about the boss constantly spawning parts and dealing special attacks, then check out PartCache:
PartCache works by keeping a cache of parts already in your workspace but really far away where no-one could see them. Every time you need it, it just changes the part’s CFrame to teleport it to where you want and when you’re finished with it, you can reuse the part and teleport it back. If you ever run out of parts in the cache, then it will create new parts as necessary. Setting the CFrame is the least expensive way because putting anything in workspace would require the game to update the physics of each part.
The Clone() function should work fine without any lag on the server or client side. The only time when the clone laggs for instance is when you are cloning particles such as Fire with high size in properties or even decreasing and increasing the size of it with a script. This may cause a lot of server side usage.