I am trying to make a tycoon with droppers, a specific dropper has the following code inside it:
wait(2) workspace:WaitForChild("PartStorage") while true do wait(1.5) -- How long in between drops local part = Instance.new("Part",workspace.PartStorage) part.BrickColor=script.Parent.Parent.Parent.DropColor.Value part.Material=script.Parent.Parent.Parent.MaterialValue.Value local cash = Instance.new("IntValue",part) cash.Name = "Cash" cash.Value = 5 -- How much the drops are worth part.CFrame = script.Parent.Drop.CFrame - Vector3.new(0,1.4,0) part.FormFactor = "Custom" part.Size=Vector3.new(1.2, 1.2, 1.2) -- Size of the drops part.TopSurface = "Smooth" part.BottomSurface = "Smooth" game.Debris:AddItem(part,20) -- How long until the drops expire end
My question is; how would I change this script so that it copies the part located at script.Parent.DropPart instead of creating an entirely new part?
I am new to Roblox lua so explanations in detail would be helpful, thanks!
Use the Clone()
function to return a copy of the object.
In your case, it would look something like this:
local Clone = script.Parent.DropPart:Clone() -- Copies the part Clone.Parent = game.Workspace -- Parents it to the workspace
If this answers your question, please mark this as the best answer!