Help with UIGridLayout Cell Padding

Every time there is a frame added the cell padding will increase I want it to be like this:
image

But the result is this:

image

Local Script

script.Parent.Player1Inventory.Main.ChildAdded:Connect(function()
	script.Parent.Player1Inventory.Main.CanvasSize = UDim2.new(0, 0, 0, script.Parent.Player1Inventory.Main.UIGridLayout.AbsoluteContentSize.Y + 200)
	
end)

script.Parent.Player2Inventory.Main.ChildAdded:Connect(function()
	script.Parent.Player2Inventory.Main.CanvasSize = UDim2.new(0, 0, 0, script.Parent.Player2Inventory.Main.UIGridLayout.AbsoluteContentSize.Y + 200)
end)

script.Parent.Player1Inventory.Main.ChildRemoved:Connect(function()
	script.Parent.Player1Inventory.Main.CanvasSize = UDim2.new(0, 0, 0, script.Parent.Player1Inventory.Main.UIGridLayout.AbsoluteContentSize.Y + 200)
end)

script.Parent.Player2Inventory.Main.ChildRemoved:Connect(function()
	script.Parent.Player2Inventory.Main.CanvasSize = UDim2.new(0, 0, 0, script.Parent.Player2Inventory.Main.UIGridLayout.AbsoluteContentSize.Y + 200)
end)

Is your cell padding using scale, rather than offset? If having more rows and a taller canvas increases the vertical padding, the only thing I could think of is that you’re using scale for your padding, meaning the space between each cell is proportional to the entire canvas size.

Your script doesn’t seem to do anything with the padding as far as I can tell, so I don’t think that would be it.

Here’s an example of scale versus offset in a UIGridLayout object:
image

so im gonna use offset instead of scale?

Yeah, for the vertical padding in the UIGridLayout.

ill test it out if it worked ill mark you as solution.

my uigridlayout is set to horizontal is it okay to set the cell padding to offset?

I meant like the padding in the y-axis. The direction of your items shouldn’t matter I don’t think. image
Make the scale 0 and put like 5 or 10 or however many pixels you want for the offset.

Sorry for the confusion.

1 Like

Thank you for helping me it worked.