- What do you want to achieve?
Given a part, I want to find the maximum and minimum Y values at which the camera does not go out of the part.
- What is the issue?
It works perfectly with other cameras, but not with workspace.currentcamera. It seems to be because the viewportsize is different.
camZoom indicates how far the camera is from the part.
local h = math.tan(math.rad(cam.FieldOfView / 2)) * camZoom
local top, bottom = part.Size.Y / 2, - part.Size.Y / 2
return top - h, bottom + h