How to Tween Field of View?

I am making a shift to sprint script that when you press shift it increases movement speed and zooms out the camera. I was wondering if there is any way to tween the FOV pullback so that it looks a lot more smooth, rather than just instantly. I can’t really figure out how you would manipulate the camera FOV to increase by a value when a tween is played, so hopefully you can help :smile:

19 Likes

You’d do it just like you’d normally do a tween;

local Properties = {FieldOfView = 100} -- change the number as you wish
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut) -- edit as you want
local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, Info, Properties)
T:Play()
12 Likes

try using for i loops:

for i = 1, (your choice) do
    FieldOfVeiw = FieldOfView + 1
    wait()
end
1 Like

I wouldn’t recommend trying to tween something such as Field of View using a For loop, as it’s an outdated method when TweenService exists.

4 Likes

How would I do it so that the field of view increases by 10, rather than being set to one specific number? Like this?

local Properties = {FieldOfView = FieldOfView + 10} -- change the number as you wish
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut) -- edit as you want
local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, Info, Properties)
T:Play()
4 Likes

Please don’t use for loops when tweenservice exists, for loops for this sort of stuff is just horrible imo.

3 Likes

Yeah, although I’d recommend keeping the default as a value so you don’t stack field of view too much, like so:

local DefaultFoV = 70

local Properties = {FieldOfView = DefaultFoV + 10}
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut) -- edit as you want
local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, Info, Properties)
T:Play()
35 Likes

I just felt that that would be more simple, but, now that I know that there is a better way, I will use it, thank you for telling me. :smiley:

3 Likes

Thanks so much, works perfectly!

3 Likes

No problem. For other users to have easy access to the answer, please mark it as the solution by clicking that little check box by the Like button.

Always happy to help!

3 Likes

How would I go about reversing this? So if I stopped holding a keybind like shift it tweens back to the default fov.

1 Like

You could create a new tween and remove the + 10 from the second line and use InputEnded to check if you stop holding a keybind.

yeah i figured that out but i figured it out by chance and idk how i did