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

Why is this script not working?

Asked by 8 years ago

I would like this script to remove the parent part when the joint is broken. Can anyone help me?

if
    script.parent["Following Brick_weld"] == nil 
then
    script.Parent:Destroy()

end

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

Well, you'd need to be able to detect when it's destroyed, so I recommend using the ChildRemoved event. So:

script.Parent.ChildRemoved:connect(function(part)
    if part.Name == "Following Brick_weld" then
        script.Parent:Destroy()
    end
end)
0
Thanks man! That certainly seemed to fix it. Naughtyrobot 0 — 8y
Ad

Answer this question