For example, say I want to clone a specific part several times in a script. What would be more efficient, to define it all as a variable at the beginning of the script or to actually create the part and place it inside the script?
Defined Part Example:
local Part = Instance.new("Part") Part.CanCollide = false Part.Size = Vector3.new(2,2,2) Part.Transparency = 1 script.Parent.Touched:connect(function() local newpart = Part:clone() newpart.Parent = workspace end)
Pre-Made Part Example:
local Part = script:FindFirstChild("Part") script.Parent.Touched:connect(function() local newpart = Part:clone() newpart.Parent = workspace end)
I find it confusing because with the defined version, the part doesn't have to physically exist inside the script yet, whereas it does with the pre-made example. Which one would be better to use?
I'd suggest the pre-made part, because it's easier to obtain a part and give it a location and property. It's also a lot more efficient. If you have any further queries let me know.