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

How to Make A Part Disappear When It Touches A Certain Part?

I am working on a conveyor belt with parts and I placed a big brick so the part touches the brick, what script do I put to make the brick destroy the item that touches it?

This is for a tycoon.

What I want to happen: Items: Conveyor Belt, Part, Brick. What happens: Parts are on Conveyor belt, once part touches brick, the part disappear, (gets removed from Workspace).

1 comment

0

Look for it in freemodels! Seriously dude, search for "Tycoon starter kit"

2 answers

All you need is a simple 'Touched()' event to get this working. You should also note however that whenever you used this event, at least one of the parts has to be UNanchored.


Here's how you would do it:

script.Parent.Touched:connect(function(Part) --Fires the function when brick is touched
	Part:remove() --Removes the part
end)

This is really all you need for that. It's pretty simple to do, just like I said.


So anyways, if you have any further problems/questions please leave a comment below, and I'll see what I can do. Hope I helped :P

7 comments

0

Should I put the script in the parts or the brick that removes anything that touches it?

0

Brick that removes it

0

Thanks

0

No prob dude.

0

why arent you using destroy bro

0

dude... remove is deprecated

0

dude...remove works fine. I like it better than Destroy, so just...yea.

Late answer, but if you want to find out what part touches it, this is what I would do:

function Touched(otherPart)
	if otherPart.Name == "Part that removes it" then
		otherPart:Destroy()
	end
end

script.Parent.Touched:connect(Touched)

WHAT THE HELL I AM SUCH AN IDIOT ON PUTTING IT TO DESTROY THE PARENT OF THE SCRIPT D:

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