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

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

Asked by 9 years ago

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).

0
Look for it in freemodels! Seriously dude, search for "Tycoon starter kit" Validark 1580 — 9y

2 answers

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

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

0
Should I put the script in the parts or the brick that removes anything that touches it? IBuildOn 15 — 9y
0
Brick that removes it dyler3 1510 — 9y
0
Thanks IBuildOn 15 — 9y
0
No prob dude. dyler3 1510 — 9y
View all comments (3 more)
0
why arent you using destroy bro drew1017 330 — 9y
0
dude... remove is deprecated unmiss 337 — 9y
0
dude...remove works fine. I like it better than Destroy, so just...yea. dyler3 1510 — 9y
Ad
Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
9 years ago

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:

Answer this question