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

If Block Has Specific Parent?

Asked by 9 years ago

Sorry for the repetitive questions, but I am working on learning by doing and I think that this is the best way to figure something out if I don't know the correct terminology to search.

script.Parent.Catch.Touched:connect(function(otherPart)
    print(otherPart)
    if otherPart == script.Parent.Parent.Parent.MoneyBricks then otherPart:Destroy()
        print ("Part deleted")
    end
end)

In this script I'm trying to set a requirement for a block, if it's parent is "MoneyBricks" then it would be deleted, but this script doesn't work and I was curious for the correct way to go about doing this.

1 answer

Log in to vote
1
Answered by 9 years ago
script.Parent.Catch.Touched:connect(function(otherPart)
    print(otherPart)
    if otherPart.Parent == script.Parent.Parent.Parent.MoneyBricks then
    otherPart:Destroy()
        print ("Part deleted")
    end
end)

You were mostly correct, you want to check the Parent of otherPart and then remove it. Parent is a property of otherPart so you can just check if otherPart.Parent equals something.

0
Oh, yeah, that would make sense, thank you! carcanken 65 — 9y
0
No problem :) YellowoTide 1992 — 9y
Ad

Answer this question