Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make inventory Unequip?

Asked by
nicros 165
8 years ago

So ive got this inventory system, its basic and uses players backpack to get the items (I did not write it because im a noob, i just eddited it to what i needed) but my problem is it doesnt unequip, when u click the button it pulls out the sword, and when u click it again, it pulls the sword out again. so my question is, how do i make this put the sword away when u click it again?

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
    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)
1
I want you to go line by line of this script, saying aloud what each line does. The answer to your question is in your script Validark 1580 — 8y
0
so im guessing its 30 and 31, it unequips then requips instantly, how do i fix that? to make it do the opposite of what is activated? nicros 165 — 8y

Answer this question