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

Keep GUI open all the time (read more for explanation)?

Asked by
nicros 165
8 years ago

so, atm i have an inventory script i found and modified and it required u to push a button to open it....i was fine with this but redesigned how im using it and now i need it open by default.

so my question is, how would i modify this to make it stay open by default instead of needing to press a button first?

here is the script

wait(.5)

player = game.Players.LocalPlayer

game.StarterGui:SetCoreGuiEnabled('Backpack',false)

--
local Enabled = false


function UpdateInventory()
    if Enabled == false then
        Enabled = true
        script.Parent.Frame.Visible = true
        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
        Enabled = false
        script.Parent.Frame.Visible = false
    end
end

script.Parent.InvenButton.MouseButton1Down:connect(function()
    UpdateInventory()
end)

player.Backpack.Changed:connect(function()
    if Enabled == false then Enabled = true UpdateInventory() end
    if Enabled == true then Enabled = false UpdateInventory() end
end)
0
Just make it visible... Perci1 4988 — 8y

1 answer

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
8 years ago
wait(.5)

player = game.Players.LocalPlayer

game.StarterGui:SetCoreGuiEnabled('Backpack',false)

local Enabled = false


function UpdateInventory()
    if Enabled == false then
        Enabled = true
        script.Parent.Frame.Visible = true
        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
        Enabled = false
        script.Parent.Frame.Visible = false
    end
end
UpdateInventory() --Run the first time

script.Parent.InvenButton.MouseButton1Down:connect(function()
    UpdateInventory()
end)

player.Backpack.Changed:connect(function()
    if Enabled == false then Enabled = true UpdateInventory() end
    if Enabled == true then Enabled = false UpdateInventory() end
end)

Ad

Answer this question