I want to destroy only the currently equipped tool, not all tools in backpack

Hi, I’m trying to make it to where when the player presses E near a block it will delete the tool the player is currently holding but leave the rest of the tools in the backpack. The only way I was able to delete the tool was to unequip the tool and delete all the tools from the backpack by putting this script inside a ProximityPrompt. How do I only delete the currently equipped tool? I’m still learning but I’m trying.

local prompt = script.Parent

prompt.Triggered:Connect(function(player)
	local backpack = player.Backpack

	local char = player.Character
	if not char then return end

	local hum = char.Humanoid
	hum:UnequipTools()
	wait()

	for _,tool in pairs(backpack:GetChildren()) do
		tool:Destroy()
	end
end)
1 Like

Equipped tools are inside the Character, so you would want to do something like this:

if character:FindFirstChildWhichIsA("Tool") then
character:FindFirstChildWhichIsA("Tool"):Destroy()
end
7 Likes

In a server script or local script?

The whole script above should be in a server script, what you coded already + my section. Also don’t forget to remove the :Unequip part.

1 Like

That worked! Thank you so much!

1 Like