What better: Clone() objects, or Instance.new(), if I need change some params?

Hello. Today I got one question - what better: Clone() or Instance.new()?
I think when I need copy of object, Clone() will be better, but what’s about when I need change some params?

local DownButton = Instance.new("ImageButton")
DownButton.Name = "DownButton"
DownButton.BackgroundTransparency = 1
DownButton.Size = UDim2.new(0, 200, 0, 90)
DownButton.Position = UDim2.new(0.5, 0, 0, BrushHolderSizeY)
DownButton.AnchorPoint = Vector2.new(0.5, 0)
DownButton.ZIndex = 175
GUIforRecoloring[DownButton] = "Basic"
DownButton.Image = "http://www.roblox.com/asset/?id=10815539520"
DownButton.ImageRectSize = Vector2.new(256, 256)

--AND problem is here:
local UpButton = DownButton:Clone()
UpButton.Name = "UpButton"
UpButton.ImageRectOffset = Vector2.new(256,0)
UpButton.Position = UDim2.new(0.5, 0, 0, BrushHolderSizeY + 40)
GUIforRecoloring[UpButton] = "Basic"
--Or
local UpButton = Instance.new("ImageButton")
UpButton .Name = "UpButton"
UpButton.BackgroundTransparency = 1
UpButton.Size = UDim2.new(0, 200, 0, 90)
UpButton.Position = UDim2.new(0.5, 0, 0, BrushHolderSizeY + 40)
UpButton.AnchorPoint = Vector2.new(0.5, 0)
UpButton.ZIndex = 175
GUIforRecoloring[UpButton] = "Basic"
UpButton.Image = "http://www.roblox.com/asset/?id=10815539520"
UpButton.ImageRectSize = Vector2.new(256, 256)
UpButton.ImageRectOffset = Vector2.new(256,0)

It’s up to you!
But i would reccomend to use :Clone()

Clone is faster! You first example of cloning and then changing some properties is the ideal route, and avoids redundant lines of code.

2 Likes

Clone is nice in that it typically reduces the amount of code but it is roughly as efficient as Instance.new.

1 Like