Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
thesit123 509 Moderation Voter
6 years ago

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

Ad

Answer this question