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

How to destroy a brick without locking its parents?

Asked by
emite1000 335 Moderation Voter
10 years ago

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

Log in to vote
1
Answered by
Maxomega3 106
10 years ago

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.~

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 emite1000 335 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

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. 
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. emite1000 335 — 10y
0
You need to do it in a function. I will edit my answer. fahmisack123 385 — 10y
0
Or you can do the answer below fahmisack123 385 — 10y
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 emite1000 335 — 10y
Log in to vote
-1
Answered by 10 years ago

you can try the :Clear() method

0
Clear is used to remove Terrain.. not parts. emite1000 335 — 10y
0
then try the :Remove() from above AverageHackerman 0 — 10y

Answer this question