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

How to make the tool get destroy with part?

Asked by 5 years ago

Hello! So I have this script where when a tool is tossed on a part, the part gets destroyed, now I want to add onto it where when the part gets destroyed WITH the tool, so they have to go get another tool in order to break all the parts. Here is the script to add onto:

script.Parent.Touched:Connect(function(p)
    if p.Parent.Name == "WhiteBall" then
        script.Parent:Destroy()
    end
end)

If you cannot tell I am not experienced with scripting, so help is needed. Thank you!

0
what has the tool touched though? Cynical_Innovation 595 — 5y
0
ik it has touched a part but have you defined the part? Cynical_Innovation 595 — 5y
0
@14zanderbilt the part is named "Plate" if you have any further questions dm me on discord @ #penn#7695 PxnnPenguinx 10 — 5y
0
@PxnnPenguinx it says that your username is not found and either does not exist or is spelled wrong. did you spell it correctly? Cynical_Innovation 595 — 5y
View all comments (2 more)
0
@PxnnPenguinx i was wondering if we could chat thru your group instead cuz im not very familiar with the discord. anyways thx! Cynical_Innovation 595 — 5y
0
nvm i found u Cynical_Innovation 595 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

One action:

p.Parent:Destroy()

Obviously you should destroy the p.Parent first so that the script continues to run. Self destruct always comes last.

Ad
Log in to vote
0
Answered by
Loot_O 42
5 years ago
script.Parent.Touched:Connect(function(p)
        if p.Parent.Name == "WhiteBall" then
               script.Parent:Destroy()
        end
end)

In the code up there, I put p.Parent because if I didn't it would see the hit part as "Handle" Also, the code up there is the script for the part that gets hit by the ball.

script.Parent.Touched:Connect(function(p)
        if p.Name == "Insert the part name here" then
               script.Parent:Destroy()
        end
end)

In the code up there, this has to be inserted inside the tool, also you should name the part that's gonna get destroyed with the tool that's different than all the other parts name. I'm telling you to do this because if there were 10 parts that were named the same and the code above was looking for a part named that, all of them can be destroyed by the ball.

Answer this question