Help with sprinting FOV

So I need help fixing my sprinting FOV. When you spam the sprint button, it would zoom in or out a lot.

local defaultFOV = currentCamera.FieldOfView
local currentFOV = defaultFOV

local cameraTween

local function setCameraTweenNil()
	if cameraTween then
		cameraTween:Pause()
		cameraTween = nil
	end
end

local function tweenCamera(fov)
	setCameraTweenNil()
	local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
	cameraTween = TweenService:Create(currentCamera, tweenInfo, {FieldOfView = fov})
	cameraTween:Play()
end

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if not gameProcessed then
		if input.KeyCode == Enum.KeyCode.LeftShift then
			local newFOV = (defaultFOV + 10)
			tweenCamera(newFOV)
			currentFOV = newFOV
		end
	end
end)

UserInputService.InputEnded:Connect(function(input, gameProcessed)
	if not gameProcessed then
		if input.KeyCode == Enum.KeyCode.LeftShift then
			local newFOV = (currentFOV - 10)
			tweenCamera(newFOV)
		end
	end
end)

currentCamera:GetPropertyChangedSignal("FieldOfView"):Connect(function()
	--defaultFOV = currentCamera.FieldOfView
end)

This might be happening because the GetPropertyChangedSignal connected function sets the new ‘default’ when it’s not the actual new default; just the FOV being changed by the tweens.

It works but what if the player changes their fov to something else?

Also, new code.

Create a separate value for the default. The FOV doesn’t change by default but if you have something in place to adjust the default FOV then you can just store a value somewhere either in the script or a instance value like a NumberValue.