Make this function unequip when equipped and vise versa?
So ive got an inventory script im using and this is the part that equips when you click on the sword icon, but idk how to make it equip if its uneqipped and unequip when its equipped. atm it just unequips then instantly equips, please help?
01 | for i,v in pairs (player.Backpack:GetChildren()) do |
02 | Obj 1 = Instance.new( 'ImageButton' ,script.Parent.Frame) |
04 | Obj 1. Size = UDim 2. new( 0 , 40 , 0 , 40 ) |
05 | Obj 1. Position = UDim 2. new( 0 , 45 *i- 40 , 0 , 7 ) |
06 | Obj 1. BackgroundTransparency = 0 |
07 | Obj 1. Image = v.TextureId |
08 | Obj 1. MouseButton 1 Down:connect( function () |
09 | player.Character.Humanoid:UnequipTools() |
10 | player.Character.Humanoid:EquipTool(v) |