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

How to destroy (remove) part that I cloned, if it doesn't exist yet?

Asked by
NorteX_tv 101
5 years ago

I cloned a part in script, by doing:

local ptc = script.Parent.PartToClone
local clonePart = ptc:Clone()

How can I now remove it (destroy) in the same script? (if I do:

ptc:Destroy()

it throws error that this part doesn't exist, because needs to be created (before clone))

0
i feel like I'm not getting something here, can't you just do clonePart:Destroy()? theking48989987 2147 — 5y
1
No, because it returns something like: ptc:Clone():Destroy() so it clones and then removes itself NorteX_tv 101 — 5y
0
What about, maybe, getting cloned part? But how? NorteX_tv 101 — 5y
0
It does exist. You're just destroying it right after it's cloned. Putting a wait() in between with some interval can show you what's going on. xPolarium 1388 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Simple what you have to do is

ClonePart.Parent = ServerStorage

if assert(ClonePart, "invalid") then ClonePart:Destroy() end

Ad

Answer this question