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

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

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))

4 comments

0

i feel like I'm not getting something here, can't you just do clonePart:Destroy()?

1

No, because it returns something like: ptc:Clone():Destroy() so it clones and then removes itself

0

What about, maybe, getting cloned part? But how?

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.

1 answer

✓ Accepted answer

Simple what you have to do is

ClonePart.Parent = ServerStorage

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

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