ScrollingFrame=NewGui("\083\099\114\111\108\108\105\110\103\070\114\097\109\101","\083\099\114\111\108\108\105\110\103\070\114\097\109\101")ScrollingFrame.Selectable=false ScrollingFrame.CanvasSize=UDim2.new(0,0,0,0)ScrollingFrame.Parent=InventoryFrame UIGridFrame=NewGui("\070\114\097\109\101","\085\073\071\114\105\100\070\114\097\109\101")UIGridFrame.Selectable=false UIGridFrame.Size=UDim2.new(1,-(ICON_BUFFER*2),1,0)UIGridFrame.Position=UDim2.new(0,ICON_BUFFER,0,0)UIGridFrame.Parent=ScrollingFrame UIGridLayout=Instance.new("\085\073\071\114\105\100\076\097\121\111\117\116")UIGridLayout.SortOrder=Enum.SortOrder.LayoutOrder UIGridLayout.CellSize=UDim2.new(0,ICON_SIZE,0,ICON_SIZE)UIGridLayout.CellPadding=UDim2.new(0,ICON_BUFFER,0,ICON_BUFFER)UIGridLayout.Parent=UIGridFrame ScrollUpInventoryButton=MakeVRRoundButton("\083\099\114\111\108\108\085\112\066\117\116\116\111\110","\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\117\105\047\066\097\099\107\112\097\099\107\047\083\099\114\111\108\108\085\112\065\114\114\111\119\046\112\110\103")ScrollUpInventoryButton.Size=UDim2.new(0,34,0,34)ScrollUpInventoryButton.Position=UDim2.new(.5,-ScrollUpInventoryButton.Size.X.Offset/2,0,INVENTORY_HEADER_SIZE+3)ScrollUpInventoryButton.Icon.Position=ScrollUpInventoryButton.Icon.Position-UDim2.new(0,0,0,2)ScrollUpInventoryButton.MouseButton1Click:Connect(function()ScrollingFrame.CanvasPosition=Vector2.new(ScrollingFrame.CanvasPosition.X,Clamp(0,ScrollingFrame.CanvasSize.Y.Offset-ScrollingFrame.AbsoluteWindowSize.Y,ScrollingFrame.CanvasPosition.Y-(ICON_BUFFER+ICON_SIZE)))end)ScrollDownInventoryButton=MakeVRRoundButton("\083\099\114\111\108\108\068\111\119\110\066\117\116\116\111\110","\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\117\105\047\066\097\099\107\112\097\099\107\047\083\099\114\111\108\108\085\112\065\114\114\111\119\046\112\110\103")ScrollDownInventoryButton.Rotation=180 ScrollDownInventoryButton.Icon.Position=ScrollDownInventoryButton.Icon.Position-UDim2.new(0,0,0,2)ScrollDownInventoryButton.Size=UDim2.new(0,34,0,34)ScrollDownInventoryButton.Position=UDim2.new(.5,-ScrollDownInventoryButton.Size.X.Offset/2,1,-ScrollDownInventoryButton.Size.Y.Offset-3)ScrollDownInventoryButton.MouseButton1Click:Connect(function()ScrollingFrame.CanvasPosition=Vector2.new(ScrollingFrame.CanvasPosition.X,Clamp(0,ScrollingFrame.CanvasSize.Y.Offset-ScrollingFrame.AbsoluteWindowSize.Y,ScrollingFrame.CanvasPosition.Y+(ICON_BUFFER+ICON_SIZE)))end)ScrollingFrame.Changed:Connect(function(z)if z=="\065\098\115\111\108\117\116\101\087\105\110\100\111\119\083\105\122\101"or z=="\067\097\110\118\097\115\080\111\115\105\116\105\111\110"or z=="\067\097\110\118\097\115\083\105\122\101"then local z=ScrollingFrame.CanvasPosition.Y~=0 local p=ScrollingFrame.CanvasPosition.Y<ScrollingFrame.CanvasSize.Y.Offset-ScrollingFrame.AbsoluteWindowSize.Y ScrollUpInventoryButton.Visible=z ScrollDownInventoryButton.Visible=p end end)
-- Make the ScrollingFrame, which holds the rest of the Slots (however many)
ScrollingFrame = NewGui("ScrollingFrame", "ScrollingFrame")
ScrollingFrame.Selectable = false
ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
ScrollingFrame.Parent = InventoryFrame

UIGridFrame = NewGui("Frame", "UIGridFrame")
UIGridFrame.Selectable = false
UIGridFrame.Size = UDim2.new(1, -(ICON_BUFFER * 2), 1, 0)
UIGridFrame.Position = UDim2.new(0, ICON_BUFFER, 0, 0)
UIGridFrame.Parent = ScrollingFrame

UIGridLayout = Instance.new("UIGridLayout")
UIGridLayout.SortOrder = Enum.SortOrder.LayoutOrder
UIGridLayout.CellSize = UDim2.new(0, ICON_SIZE, 0, ICON_SIZE)
UIGridLayout.CellPadding = UDim2.new(0, ICON_BUFFER, 0, ICON_BUFFER)
UIGridLayout.Parent = UIGridFrame

ScrollUpInventoryButton = MakeVRRoundButton("ScrollUpButton", "rbxasset://textures/ui/Backpack/ScrollUpArrow.png")
ScrollUpInventoryButton.Size = UDim2.new(0, 34, 0, 34)
ScrollUpInventoryButton.Position =
	UDim2.new(0.5, -ScrollUpInventoryButton.Size.X.Offset / 2, 0, INVENTORY_HEADER_SIZE + 3)
ScrollUpInventoryButton.Icon.Position = ScrollUpInventoryButton.Icon.Position - UDim2.new(0, 0, 0, 2)
ScrollUpInventoryButton.MouseButton1Click:Connect(function()
	ScrollingFrame.CanvasPosition = Vector2.new(
		ScrollingFrame.CanvasPosition.X,
		Clamp(
			0,
			ScrollingFrame.CanvasSize.Y.Offset - ScrollingFrame.AbsoluteWindowSize.Y,
			ScrollingFrame.CanvasPosition.Y - (ICON_BUFFER + ICON_SIZE)
		)
	)
end)

ScrollDownInventoryButton = MakeVRRoundButton("ScrollDownButton", "rbxasset://textures/ui/Backpack/ScrollUpArrow.png")
ScrollDownInventoryButton.Rotation = 180
ScrollDownInventoryButton.Icon.Position = ScrollDownInventoryButton.Icon.Position - UDim2.new(0, 0, 0, 2)
ScrollDownInventoryButton.Size = UDim2.new(0, 34, 0, 34)
ScrollDownInventoryButton.Position =
	UDim2.new(0.5, -ScrollDownInventoryButton.Size.X.Offset / 2, 1, -ScrollDownInventoryButton.Size.Y.Offset - 3)
ScrollDownInventoryButton.MouseButton1Click:Connect(function()
	ScrollingFrame.CanvasPosition = Vector2.new(
		ScrollingFrame.CanvasPosition.X,
		Clamp(
			0,
			ScrollingFrame.CanvasSize.Y.Offset - ScrollingFrame.AbsoluteWindowSize.Y,
			ScrollingFrame.CanvasPosition.Y + (ICON_BUFFER + ICON_SIZE)
		)
	)
end)

ScrollingFrame.Changed:Connect(function(prop)
	if prop == "AbsoluteWindowSize" or prop == "CanvasPosition" or prop == "CanvasSize" then
		local canScrollUp = ScrollingFrame.CanvasPosition.Y ~= 0
		local canScrollDown = ScrollingFrame.CanvasPosition.Y
			< ScrollingFrame.CanvasSize.Y.Offset - ScrollingFrame.AbsoluteWindowSize.Y

		ScrollUpInventoryButton.Visible = canScrollUp
		ScrollDownInventoryButton.Visible = canScrollDown
	end
end)
