How to make the selected object fit inside viewport frame

My script:

viewportCamera.CFrame = CFrame.new(Vector3.new(0, 2, 12), Object.Handle.Position)

The result:

The selected object is bigger than the viewport frame and doesn’t fit, how can I fix this?

1 Like

try using this?
https://www.roblox.com/library/5165030669/

or maybe like

local handle = Object.Handle.Position
viewportCamera.CFrame = CFrame.new(Vector3.new(0, 2, 12 + handle.Size.Magnitude), handle)
1 Like