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

If Block Has Specific Parent?

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

✓ Accepted answer
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.

2 comments

0

Oh, yeah, that would make sense, thank you!

0

No problem :)

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