Cloning optimisation

My question is pretty simple. Which is more optimised:

1- Create an explosion with Instance.new and enter all the properties with script

2- Make the exact replica I want inside the script, clone it and put it where I want.

I feel like cloning it is way more efficient since I dont change any of the properties but I see everyone using Instance.new.

Is there a reason why?

Example:

-- 1
local explosion = Instance.new("Explosion",workspace)
explosion.BlastRadius = 10
explosion.DestroyJointRadiusPercent = 0

-- 2
local explosion = script.explosionOriginal:Clone()
explosion.Parent = workspace

i dont understand what your trying to achive here.

if you mean that the cloned explosion is in the script then do

local explosion = script.explosionOriginal:Clone()
explosion.Parent = script.Parent.yourscriptsnamehere

I know how to make an explosion. My question is why do people opt for creating the explosion from 0 instead of just making it the way you like and just cloning it when needed.

I simply want to know which ones more optimised for server performance.

For all I know, they are both basically the same. Do whatever you prefer. Cloning still will set the properties as if you did it manually on a new explosion.

1 Like

you should do

local explosion = script.explosionOriginal
explosion:Clone()
explosion.Parent = workspace

Alright, I guess Ill use clones since its easier to modify afterwards. Thank you <3

1 Like

Thats not what I need xD
The question isnt about how to clone.

oh well you made it pretty hard to understand for me sorry

Probably number 1, because at some point, you’ll have a lot of instances stored to be cloned, while for explosion, they should just be created, not cloned. Explosion is something that is easily created and deleted.

My bet is that cloning is faster, because then all the properties are set by the engine in C++ instead of in Lua. But the difference would probably be so minor that you should just use what you prefer. Like others have said.

You could do a speed test to see which is faster.

1 Like

I know this post is already solved, but I would like to add that you should absolutely not use the parent argument in Instance.new(). The parent should always be set after the properties.

More information can be found in this post: https://devforum.roblox.com/t/psa-dont-use-instancenew-with-parent-argument

Oh wow, really interesting. Thanks for the info :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.