This sounds simple but isn’t,
what I want to do is to have a max X and max Y plane so in this case 78.25 Y studs and 139.5 X studs and make the camera see the whole part ALWAYS!
So in other words this plane represents the perfect viewport frame size:
I did it!
For anybody trying to do the same here’s all you need to do : )
local DistanceX = 139.5 / math.tan(math.rad(1))/(game.Workspace.Camera.ViewportSize.X / game.Workspace.Camera.ViewportSize.Y) -- Cauculating the X distance of X
local DistanceY = (78.25 / math.tan(math.rad(1))) -- Cauculating the X distance of Y
local ChosenDistance = math.max(DistanceX, DistanceY) -- Chooses the biggest value of X and Y
game.Workspace.Camera.CFrame = CameraPart.CFrame * CFrame.new(0,0, ChosenDistance)
If you continuously update these values the camera will always fit the part inside the viewport size!