I came upon this post and wanted to double check if :Clone() was actually slower in a real-world environment. Below are the timed results of three functions, each creating 256 parts with various properties changed, run five times.
For Instance.new
0.0027773380279541016
0.0024547576904296875
0.0025026798248291016
0.0026025772094726562
0.0024390220642089844
For :Clone()
0.003247976303100586
0.0029532909393310547
0.0030412673950195312
0.0029115676879882812
0.003021240234375
For Instance.fromExisting
0.0029854774475097656
0.002967357635498047
0.003371000289916992
0.002826213836669922
0.0026302337646484375
Just for the record - and for the sake of any developers like me who stumbled upon this wondering which would be best for performance - Instance.new is still faster. Instance.fromExisting is 2nd with :Clone() not far behind it.
If you would like to fact-check, the script I used is below. This is ripped from a game I’m devving (yay real world testing), so you’ll need to add a folder named “Map” (or just remove those parts so it gets parented to workspace). Uncomment one comment block at a time each time you run it to test the three methods.
function createWindowPieces()
local start = tick()
--[[
for i = 1, 256 do
local part = Instance.new("Part")
part.Size = Vector3.new(.25, .25, .25)
part.Color = Color3.new(0, 1, 1)
part.Transparency = .75
part.Position = Vector3.new(61.75, 7, -57)
part.Parent = workspace.Map
part:ApplyImpulse(Vector3.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1)))
end
]]
--[[
local part = Instance.new("Part")
part.Size = Vector3.new(.25, .25, .25)
part.Color = Color3.new(0, 1, 1)
part.Transparency = .75
part.Position = Vector3.new(61.75, 7, -57)
part.Parent = workspace.Map
part:ApplyImpulse(Vector3.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1)))
for i = 1, 255 do
local newPart = part:Clone()
newPart.Parent = workspace.Map
end
]]
----[[
local part = Instance.new("Part")
part.Size = Vector3.new(.25, .25, .25)
part.Color = Color3.new(0, 1, 1)
part.Transparency = .75
part.Position = Vector3.new(61.75, 7, -57)
part.Parent = workspace.Map
part:ApplyImpulse(Vector3.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1)))
for i = 1, 255 do
local newPart = Instance.fromExisting(part)
newPart.Parent = workspace.Map
end
--]]
print(tick() - start)
task.wait(1)
end
createWindowPieces()
createWindowPieces()
createWindowPieces()
createWindowPieces()
createWindowPieces()