so ive got this inventory script i didnt write it, i just modified it to my liking, well it worked perfect for a long time, but while testing another thing in my game i noticed instead of unequipping a sword when its out it re-equips it as if it wasn't pulled out, making it impossible to put the sword away, i have no clue what would have changed that would cause this, can someone point out whats causing this?
here is the script
wait(.5) player = game.Players.LocalPlayer Close = game.Workspace.Close1 game.StarterGui:SetCoreGuiEnabled('Backpack',false) Close = game.Workspace.Close1 -- function UpdateInventory() if Close.Disabled == true then Close.Disabled = false elseif Close.Disabled == false then Close.Disabled = true end if Close.Disabled == false then script.Parent.Frame.Visible = true script.Parent.CenterCap.Visible = false script.Parent.Frame.CanvasSize = UDim2.new(0,46*#player.Backpack:children(),0,0) script.Parent.Frame:ClearAllChildren() for i,v in pairs(player.Backpack:GetChildren()) do Obj1 = Instance.new('ImageButton',script.Parent.Frame) Obj1.ZIndex = 10 Obj1.Size = UDim2.new(0,40,0,40) Obj1.Position = UDim2.new(0,45*i-40,0,7) Obj1.BackgroundTransparency = 0 Obj1.Image = v.TextureId Obj1.MouseButton1Down:connect(function() player.Character.Humanoid:UnequipTools() player.Character.Humanoid:EquipTool(v) end) end else script.Parent.Frame.Visible = false script.Parent.CenterCap.Visible = true wait(.3) end end script.Parent.InvenButton.MouseButton1Down:connect(function() UpdateInventory() end) player.Backpack.Changed:connect(function() if Close.Disabled == true then Close.Disabled = false UpdateInventory() end if Close.Disabled == false then Close.Disabled = true UpdateInventory() end end)