Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

which is faster/more efficent cloneing or creating a new instance?

Asked by 8 years ago

This may seem simple at first but when not when sailing this up to large models ect but also scripts are smaller and should replicate to the client faster when compared to large models?

Scenario 1 creating a projectile using clone :-

local bullet  = -- stored pre made bullet

local newBullet = bullet:Clone()

-- set other params ect
-- shoot bullet

Scenario 2 creating a new projectile each time:-

local bullet  = Instance.new("Part")

-- set other params ect
-- shoot bullet

I hope this explains my question but just in case another example could be, creating a model in a localscript or cloning one from the replicatedstorage.

Pls comment if you need any more info.

1 answer

Log in to vote
0
Answered by 8 years ago

It doesn't matter
Not for this, at least

There are two important rules for optimisation, particularly in Lua:

  • Rule #1: Don't do it.
  • Rule #2: Don't do it yet. (for experts only).

If your bullet has a lot of templating which means that you're setting less properties through Lua, cloning it is definitely faster, if only by microseconds.

0
scratch that, nanoseconds :D dragonkeeper467 453 — 8y
0
No I think it's probably closer to microseconds sadly, unless your CPU is fast enough. User#6546 35 — 8y
Ad

Answer this question