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)