How Do I Find The Part That Touched A Part

I Need To Find A Part That Touched A Destroy Part i.e.: Tycoon Sell Block

I Want A Solution For A Ball Touching A Part Then Being Destroyed

Example:
III
III
O <== Destroyed When Touching
_ <==

First Post So Its Bad

4 Likes

the touched function returns the part that touched it, just use that and done.

part.Touched:Connect(function(partThatTouchedLolBeans)
end)

1 Like
--specify the part
Part = script.Parent
--makes a function that fires when touching something, otherpart is the part it touches
Part.Touched:Connect(function(otherpart)
-- checks if the other part it touches is a part destroyer
if otherpart.Name == ("PartDestroyer") then
--destroy part
Part:Destroy()
end
end)

Not tested yet let me know if it works
Also name the part you want to be the destroy part “PartDestroyer” or it won’t work

1 Like

Does It Matter If “Otherpart” Needs To Be Specified In Order For It To Work

The Part Is An Instance.New Part So I Doubt It Can Be Specified

1 Like

No it doesn’t lemme edit the script and add comments so u can add it to ur game easier

Edit: Finished check it out now

1 Like

Try something like this:

local name = "Special"

script.Parent.Touched:Connect(function(hit)
	if hit:IsA("Part") and hit.Name == name then
		hit:Destroy()
	end
end)

Change the name variable to the name of the part you want to be destroyed. I tested it, and it should work.

2 Likes