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 the tool get destroy with part?

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!

6 comments

0

what has the tool touched though?

0

ik it has touched a part but have you defined the part?

0

@14zanderbilt the part is named "Plate" if you have any further questions dm me on discord @ #penn#7695

0

@PxnnPenguinx it says that your username is not found and either does not exist or is spelled wrong. did you spell it correctly?

0

@PxnnPenguinx i was wondering if we could chat thru your group instead cuz im not very familiar with the discord. anyways thx!

0

nvm i found u

2 answers

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.

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.

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