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

ScrollingFrame not working properly?

Asked by
nicros 165
9 years ago

So ive got an inventory GUI and it uses a scrolling frame that houses the buttons(items) problem is when i add enough items to force a scroll bar it instead just goes through the box and acts like its not a scrollingFrame. im thinking its probably the inventory script, but not sure...

I have ScrollingEnabled on and ClipsDecendants on.

here is the whole inventory script, im not sure what would cause this im pretty noob at LUA :/

wait(3)

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.HotBar.Visible = true
        script.Parent.Frame.CanvasSize = UDim2.new(0,0,0,20*#player.Backpack:children())
        script.Parent.Frame:ClearAllChildren()
        for i,v in pairs(player.Backpack:GetChildren()) do
            Obj1 = Instance.new('ImageButton',script.Parent.Frame)
            Obj1.Size = UDim2.new(0,40,0,40)
            Obj1.Position = UDim2.new(0,5,0,47*i-27)
            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
        script.Parent.HotBar.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)

Answer this question