In my game, I want the camera to zoom in when you aim with a gun. This is simple to do, but just changing the FOV or zoom distance values is choppy. Is there a way to smoothly do this?
✓ ANSWER ACCEPTED
Is there a way to smoothly move the player's camera position?
1 answer
✓ Accepted answer
Maybe use TweenService.
local cam = game.Workspace.CurrentCamera
local mouse = game.Players.LocalPlayer:GetMouse()
local TweenService = game:GetService("TweenService")
local debounce = false
local aiming = false
local t= .3
local info = TweenInfo.new(t, Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0) --(time,easingStyle,EasingDirection,NumberOfRepeats,canRepeat,delay)
local Forward = { FieldOfView = 60 } -- change right side of equation to whatever
local Backward = {FieldOfView = 70 }
local zoomIn = TweenService:Create(cam,info,Forward) -- these create the tweens
local zoomOut = TweenService:Create(cam,info,Backward)
mouse.Button2Down:Connect(function() --change this to whatever makes the player aim
if debounce == false then
debounce = true
zoomIn:Play() -- this plays the tween
end
end)
mouse.Button2Up:Connect(function()
if debounce == true then
debounce = false
zoomOut:Play()
end
end)
Look up tweening if you want to learn more. Also, don't forget to mark this as the answer!
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
I thought I might be able to use tweenservice, just wasn't sure it supported camera movement. Lemme try it then vouch.
The second parameter of TweenService:Create() is the table of which property of the targeted instance should be tweened, and FieldOfView is a property of the camera, so it should work.
Is there any way to move the camera slightly to the right as well? It's a third person game, so I want it to hover over their shoulder.
Search up camera manipulation, then you will find your answer.