Ad
Log in to vote
0

Why is this script not working?

Asked by 3 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 3806 Trusted Badge of Merit Snack Break Moderation Voter Administrator Community Moderator Super Administrator
3 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 — 3y
Ad

Answer this question