UIGridLayout doesn't work when creating instances

I am creating an ImageButton instance and it doesn’t seem to be effected by my UIGridLayout, both when creating one from inside the script as well as adding one via explorer.

local grid = Instance.new("UIGridLayout")
grid.Parent = script.Parent
grid.CellPadding = UDim2.fromOffset(0.2, 0.2)
grid.CellSize = UDim2.new(0.05, 0,0.05, 0)
grid.FillDirectionMaxCells = 20


for count = 0, 400, 1 do
	task.wait(0.01)
	local button = script.Parent.Buttons.Model:Clone()
	button.Visible = true
	button.Name = row
	button.Parent = script.Parent.Buttons
	button.Image = 0
	button.Size = UDim2.new(0.05, 0, 0.05, 0)
	button.Position = val
	collectionservice:AddTag(button, "Tag")
	val = val + UDim2.new(0.055, 0, 0, 0)	
	row = row + 1
end

Ensure the Grid is a child inside the same frame as all the buttons. It appears as if you are setting the Grid’s parent to something different than where the buttons are all located. Try changing the Grid’s parent to script.Parent.Buttons.