I am using the :Destroy() method to destroy a brick when it falls on the ground on a certain part. However, this is in loop, but the loop is stopped when the object is destroyed because the Destroy method "Sets the Parent property to nil, and locks the Parent property". (ROBLOX Wiki)
So after the first time it is destroyed, Workspace becomes locked....
My question is: Is there a method to get rid of a part without using the Destroy method? If not, how do I make it so it does not lock my Workspace?
No! Don't spread this bad method around!
The best way to destroy an object without locking its parent property is by setting its parent to nil.
script.Parent = nil wait (5) script.Parent = Workspace
It's better than :remove ()
since that's depreciated.
~Don't forget to click "Accept as answer" once your question is satisfied. It's near the voting system for answers.~
Use :remove()
instead of :Destroy()
. That should work I hope.
Here's what you need
Workspace -Script -Baseplate -Part
a = script.Parent.Baseplate b=script.Parent.Part while true do b:Clone() --Copies and Pastes the part b.Parent = Workspace --Makes it visible Wait() end a.Touched:connect(function(hit) if hit.Name == "Part" then --If it was the part that touched it, then continue. This makes sure it's not a Character hit:remove() end end) --This Should work, I hope.
you can try the :Clear()
method