function PetSrollingFrame.SetPetCanvasSize(u,o)PetUI.Size=UDim2.new(.515,0,.745,0)local A,D,r=getSizes()local h=ScrollingFrame.AbsoluteSize local U=A*h U=UDim2.new(0,U.X,0,U.Y)local s=D*h s=UDim2.new(0,s.X,0,s.Y)UIGridLayout.CellPadding=U UIGridLayout.CellSize=s local p=ScrollingFrame:GetChildren()local a=0 if o==true then for o,u in pairs(PetsFrame:GetChildren())do if u:IsA("\073\109\097\103\101\076\097\098\101\108")and u:FindFirstChild("\068\097\116\097")then if u.Visible==true then a=a+1 end end end else a=#p-1 end local i=ScrollingFrame.AbsoluteSize.Y local v=UIGridLayout.CellSize.Y.Offset local e=UIGridLayout.CellPadding.Y.Offset UIGridLayout.FillDirectionMaxCells=r local I=math.ceil(a/UIGridLayout.FillDirectionMaxCells)local V=I*v+(I-1)*e ScrollingFrame.CanvasSize=UDim2.new(0,0,0,V+5)if PetUI.Visible==false then PetUI.Size=UDim2.new(0,0,0,0)end end return PetSrollingFrame

function PetSrollingFrame:SetPetCanvasSize(searchOn)
	PetUI.Size = UDim2.new(0.515, 0, 0.745, 0)
	
	local PADDING, SIZE, MaxCells = getSizes()
	local AbsoluteSize = ScrollingFrame.AbsoluteSize

    local NewPadding = PADDING * AbsoluteSize
    NewPadding = UDim2.new(0, NewPadding.X, 0, NewPadding.Y)
    local NewSize = SIZE * AbsoluteSize
    NewSize = UDim2.new(0, NewSize.X, 0, NewSize.Y)
	
    UIGridLayout.CellPadding = NewPadding
    UIGridLayout.CellSize = NewSize
	
	local children = ScrollingFrame:GetChildren()
	local items = 0
	if searchOn == true then
		for _, v in pairs(PetsFrame:GetChildren()) do
			if v:IsA("ImageLabel") and v:FindFirstChild("Data") then
				if v.Visible == true then
					items = items + 1
				end
			end
		end
	else
		items = (#children) - 1
	end
	local frameSizeY = ScrollingFrame.AbsoluteSize.Y
	local ySize = UIGridLayout.CellSize.Y.Offset
	local yPadding = UIGridLayout.CellPadding.Y.Offset
	UIGridLayout.FillDirectionMaxCells = MaxCells
	local rows = math.ceil(items / UIGridLayout.FillDirectionMaxCells)
	local pixels = rows * ySize + (rows - 1) * yPadding
	ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, (pixels + 5))
	
	if PetUI.Visible == false then
		PetUI.Size = UDim2.new(0, 0, 0, 0)
	end
end

return PetSrollingFrame
