Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I clone a part from within the game? (Script provided)

I am creating a tycoon game with droppers, and I would like the part that it drops to be a clone of another part within the game (it has a mesh inside of it). Here is the current code:

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

How would I change the script in order to make the part that is dropped be a clone of script.Parent.DropPart ?

I am new to roblox lua so please explain in detail, thanks!

1 answer

:Clone() is a function that clones an object. Try: script.Parent.DropPart:Clone()

This discussion is preserved as it was. New answers, comments, and votes are closed.