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

How to destroy a brick without locking its parents?

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?

3 answers

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.

1 comment

0

The script is not in the brick though. Here, read my full script instead: https://scriptinghelpers.org/questions/3667/deleting-this-brick-without-locking-its-parent

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. 

4 comments

0

For whatever reason, that does not work... It does the first time it touches it, but every time after that the part does not get removed.

0

You need to do it in a function. I will edit my answer.

0

Or you can do the answer below

0

Read my full script instead. It will allow you to answer my question better: https://scriptinghelpers.org/questions/3667/deleting-this-brick-without-locking-its-parent

you can try the :Clear() method

2 comments

0

Clear is used to remove Terrain.. not parts.

0

then try the :Remove() from above

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