Hello,
So I got a hammer tool that successfully breaks a wooden plank when touching it. The thing is, the hammer stays in the inventory after being used and I want it to disappear. How could I adjust this code so this specific tool gets removed?
Hello,
So I got a hammer tool that successfully breaks a wooden plank when touching it. The thing is, the hammer stays in the inventory after being used and I want it to disappear. How could I adjust this code so this specific tool gets removed?
you can unequipped the tool using humanoid:UnequipTools
Then you destroy the tool in the backpack
You can destroy the tool to make it disappear, so if script.Parent
is the handle, you can just do script.Parent.Parent:Destroy()
where you want to get rid of the tool. probably as part of the Touched event
Okay didn’t realise that the first script is for the wooden plank, you can simply do hit.Parent:Destroy()
to destroy the tool
You can use
if Player.Character:FindFirstChildOfClass("Tool") then Player.Character:FindFirstChildOfClass("Tool"):Destroy() end
This destroys any equipped tool.
Would I have to make a new script in the workspace by itself so that those lines of code function properly? Or should I add that to the hammer script?
The first script, is it in the wooden plank or is it in the hammer tool?
Try putting it right after script.Parent.CanCollide
The first script is for the wooden plank, the bottom one is for the hammer.
If the script is in the wooden plank, you can do hit.Parent:Destroy()
in the if statement. If it’s in the Hammer, do script.Parent.Parent:Destroy()
instead
(Hammer script) I added the “script.Parent.Parent:Destroy()” like how you recommended but it seems to not have done anything.
(What everything looks like, maybe this can give you a better idea)
tool.Activated:Connect(function()
wait(1) --u may want to change this to a higher value depending on the amount of time ur tool takes to complete the action
tool:Destroy()
end)
So the first script is PlankScript
? in PlankScript
, do hit.Parent:Destroy()
in the if statement
Thank you so much!! It worked :))