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

How to make the tool destroy with the part?

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

✓ Accepted answer
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

2 comments

0

Thank you!

0

How do you make it where it just destroys the tool only

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