**This is an excerpt from the script of one of my toolbar slots
01 | t = script.Parent --Toolbar GUI, first slot |
02 | tool = script.Parent.ToolFolder.Tool --The assigned tool |
03 | player = game.Players.LocalPlayer --The player equipping and unequipping |
04 | equipped = false --Becomes true when the tool is equipped to signify that it is equipped |
05 |
06 | function EquipTool() --For equipping the tool |
07 | player.Humanoid:EquipTool(tool) --Code to equip the assigned tool |
08 | end |
09 |
10 | function UnequipTool() --For unequipping the tool |
11 | ??? |
12 | end |
13 |
14 | t.MouseButton 1 Up:connect( function () --Click the GUI to equip or unequip |
15 | if equipped = = false then |
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.
1 | function UnequipTool() --For unequipping the tool |
2 | tool.Parent = player.Backpack |
3 | end |
Let me know if there is any errors.