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

How do I make a part get destroyed when it touches another part?

local part = script.parent.parent.GroupOfRopes
function onTouched(part)
	script.Parent:Destroy()
end

1 comment

0

Hmm so when you touch the GroupOfRopes it destroy the parent? or when you touch the Parent it destroy the group of ropes?

2 answers

You didnt connect ontouched to part.Touched.

local part = script.parent.parent.GroupOfRopes
function onTouched(part)
    script.Parent:Destroy()
end
script.Parent.Touched:Connect(onTouched)

Okay. So I think this will work:

local part = script.parent.parent.GroupOfRopes
function onTouched(hit)
	if hit.Parent.Name == "GroupOfRopes" then
		script.Parent:remove()
end
script.Parent.Touched:Connect(onTouched)

3 comments

0

Man, someone beat me to it. If only I typed faster...

0

You're wrong. If the part touches a model called "GroupOfNets", it gets destroyed.

0

Ok

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