**This is an excerpt from the script of one of my toolbar slots
t = script.Parent --Toolbar GUI, first slot tool = script.Parent.ToolFolder.Tool --The assigned tool player = game.Players.LocalPlayer --The player equipping and unequipping equipped = false --Becomes true when the tool is equipped to signify that it is equipped function EquipTool() --For equipping the tool player.Humanoid:EquipTool(tool) --Code to equip the assigned tool end function UnequipTool() --For unequipping the tool ??? end t.MouseButton1Up:connect(function() --Click the GUI to equip or unequip if equipped == false then EquipTool() --Equip tool equipped = true elseif equipped == true then UnequipTool() --Unequip tool equipped = false end end)
The problem is that I do not know what code to put for the UnequipTool function; there is a built-in function for equipping a tool, which is EquipTool(), but there isn't one for unequipping a tool. How would I make this happen?
When a player equips a conventional tool (not a hopperbin), the tool is parented to their character from their backpack. In this respect, if you were to transport the tool back to the backpack, it would be unequipped per-say.
function UnequipTool() --For unequipping the tool tool.Parent = player.Backpack end
Let me know if there is any errors.