Im just trying to make broom system that will work when you click on part when holding a tool the part will be removed?
How to make part that will be removed when clicked on it while holding a tool?
3 answers
You can use tool.Equipped, and that will give you the player's mouse, since click detectors do not work when you hold the tool, you should use the mouse.Button1Down and mouse.Target to find out which object the player is aiming at (when clicked). Then you can fire a remote event to the server in order to destroy the part (since the whole mouse part is in the local script, the mouse is nil in a server script).
So, to sum up, you can learn using these resources:
Add a clickDetector to the part and add a script in it and write this in the script
script.Parent.MouseClick:Connect(function(clicker)
local Character = clicker.Character
if Character:FindFirstChild("toolNameHere") then
script.Parent.Parent:Destroy()
end
end)
Use this local script in the tool:
local Part = -- Reference the part in this variable
script.Parent.Equipped:Connect(function()
local ClickDetector = Instance.new("ClickDetector)
ClickDetector.Parent = Part
end)
script.Parent.Unequipped:Connect(function()
Part.ClickDetector:Destroy()
end)
Put this normal script in the part you want to get destroyed:
local Part = -- Reference the part in this variable
if Part.ClickDetector then
Part.ClickDetector.MouseClick:Connect(function()
Part:Destroy()
end)
end
These scripts makes it so when it gets clicked (only if there is a click detector, which gets put into the part if the tool is equipped) it gets destroyed, and it won't work when it is unequipped, because it gets destroyed.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Please don't give code, scripting helpers is not a request website, so you should not give code to them
Dude the whole point of this website is to ask for help and how to do things, Leamir
You can make it like @LightningLIon58, this is NOT a request website, if we just give code, we are encouraging people to ask for code