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

This script will allow a tool to equip but not unequip?

Now I have come to the issue when making my own backpack. I can equip tools but I cannot unequip them. I am a fairly new scripter, so I am confused. Here is the script:

local btn = script.Parent
local plr = game.Players.LocalPlayer
local knife = game.ServerStorage.SilverBlade
btn.MouseButton1Down:connect(function(hit)
	if hit then
		plr.Character.Humanoid:EquipTool(knife)
		if hit and plr.Character.Humanoid:EquipTool(knife) then
			plr.Character.Humanoid:UnequipTools()
		end
	end
end)

1 answer

✓ Accepted answer

So basically when you equip a tool, it adds the tool to the character. So you can use the for i, v in pairs loop. Like this

local btn = script.Parent
local plr = game.Players.LocalPlayer
local knife = game.ServerStorage.SilverBlade
local ToolEquiped = false
btn.MouseButton1Down:connect(function(hit)
    if hit and ToolEquiped == false then
        plr.Character.Humanoid:EquipTool(knife)
	ToolEquiped = true
      elseif hit and ToolEquiped == true then
	for i, v in pairs(plr.Character:GetChildren()) do
		if v:IsA("Tool") then
			v:Destroy()
		end
	end
	ToolEquiped = false
    end
end)

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