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

How to make the tool destroy with the part?

Asked by 5 years ago

Hello, so i have a script where when a tool is touched with a part that the part will be destroyed, but I also want the tool that touches to be destroyed as well. If someone could help that would be greatly appreciated! Script:

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

Basically I just want to add onto that script

1 answer

Log in to vote
1
Answered by
cegberry 432 Moderation Voter
5 years ago
Edited 5 years ago
script.Parent.Touched:Connect(function(p)
    if p.Parent.Name == "Sandbag" then -- Checks if the part's parent that was touched by the tool, is named "SandBag"
        p.Parent:Destroy() -- Destroy the touched part's parent
        script.Parent:Destroy() -- Destroy the tool along with it
    end
end)

You can just use the Touched event's parameter, to destroy the part

You can look at this if you need to, https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched

0
Thank you! PxnnPenguinx 10 — 5y
0
How do you make it where it just destroys the tool only ReaILazy -9 — 5y
Ad

Answer this question