Smooth Camera Zoom

I made an ADS (Aim down the sights) system.
And I wanna make a camera zoom, not like just changing the field of view, I wanna make it smooth zooming.

Here the current code:

		for i = 1, module.ADS_RANGE do
			local cam = workspace.CurrentCamera
			cam.FieldOfView = (70 - (i * 2))


1 Like

Heres an example code with TweenService:

local TweenService = game:GetService("TweenService")

local tweenInfo =
    0.2, -- Time
    Enum.EasingStyle.Linear, -- EasingStyle
    Enum.EasingDirection.Out, -- EasingDirection
    -1, -- RepeatCount (when less than zero the tween will loop indefinitely)
    false, -- Reverses (tween will not reverse once reaching it's goal)
    0 -- DelayTime

local tween = TweenService:Create(cam, tweenInfo, { FieldOfView = 70 - (module.ADS_RANGE * 2) })


You can find out TweenService here.


Can I have some explanations?
Why FieldOfView - (module.ADS_RANGE * 2)

Also, how do i make it tween back?

If you check TweenService’s wiki page you can see that it requires 3 arguments to create the tween Instance, TweenInfo and PropertyTable.

PropertyTable argument is actually a table that has the things to do, for this example if you set { FieldOfView = 1 } it will move the Camera’s FieldOfView to 1 smoothly.

You can find out more here:

Oh, Got it!
But I got a problem

And another thing to ask.
How do I make it tween back?

local AIM_FALSE = service:Create(workspace.CurrentCamera, ADS_FALSE, {FieldOfView = 70})

Oh, i fixed it!!
Thanks for helping.

1 Like