Camera FOV Tween Not Working

Hello. I am trying to tween local player’s camera field of view when they are running / when they stop running but it doesn’t work. I am not an expert at tweens so I need help. Thanks in advance.

local TW = game:GetService("TweenService")
local TWInfo = TweenInfo.new(.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 1, false, .8)
local outTW = TW:Create(camera, TWInfo, {["FieldOfView"] = 90})
local inTW = TW:Create(camera, TWInfo, {["FieldOfView"] = 70})
running:GetPropertyChangedSignal("Value"):Connect(function()
	
	if running.Value == true then
		outTW:Play()
		
		
	elseif running.Value == false then
		inTW:Play()
		
	end
	
end)

Hello! I recently had this problem as well, but before I offer any help, I have a few questions about how you are doing this. You say you are doing this on a local script, correct? You want to make sure you are checking for when the value is changed on the local script, as that is the only way you will be able to change the players FOV. Additionally, how are you obtaining this “running” value? Could you give a little more context?

Make sure that camera is defined as workspace.CurrentCamera, or the custom camera if you are using any.

Make sure you have cameratype set to scriptable.

camera.CameraType = Enum.CameraType.Scriptable

also make sure you cancel the tweens first.


local outPlaying=false
local inPlaying=false

running:GetPropertyChangedSignal("Value"):Connect(function()
	
	if outPlaying then outPlaying=false outTW:Cancel() end
	if inPlaying then inPlaying=false inTW:Cancel() end
	
	if running.Value == true then
		outTW:Play()
		outPlaying=true
		outTW.Completed:Wait()
		outPlaying=false
	elseif running.Value == false then
		inTW:Play()
		inPlaying=true
		inTW.Completed:Wait()
		inPlaying=false
	end 

end)
1 Like

Actually, since you just brought up the CameraType.Scriptable thing, I just want to ask if this is only for certain types of functions, because I can tween my camera FOV using CameraType.Custom just fine.

Is this a bug or am I just doing something weird lol

CameraType set to Custom is actually the default camera property, you can check the documentation out. I believe that you must change it to Scriptable first, before you mess with the cframe (this could be tweens, or whatever).

Lets take an example.
lets say I want a cut scene to play at some point of the game.
I would set the cameratype to scriptable, tween the camera, wait until the tween is done,
And then I have to make sure that the camera is back on player again.

To do that, I have to set the cameratype back to custom and then set the camerasubject to characters Humanoid and it should work.

Edit:
But yes, I don’t really think you have to change it to scriptable just for the FOV, it will still work as you’ve just said, so yep thats a mistake from my side.

1 Like

Ah, that checks out. Thanks for clarifying

The issue is already solved by @CelestialHonour but just to clarify, the running system is connected to a bool value inside the player. When you double tap W, the value becomes true, and when the value becomes true, the walk speed changes + animation plays. The issue I think was that I wasn’t taking the currentcamera.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.