Hey, I’m having issues tweening FOV, for an acceleration script. Basically, whenever the player moves, it increases their walk speed, and tweens their FOV to 120 if they’re moving, otherwise, it gets back the FOV to 70. The issue is the whenever the tween plays, it resets back to the original FOV.
local MaxSpeed = 30
local InitialFOV = 80
local MaxFOV = 120
local FOVTransitionTime = 1
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local humanoid = script.Parent.Humanoid
local TweenService = game:GetService("TweenService")
local function setFOV(fov)
if camera.FieldOfView == fov then
print("Equal")
return
end
local tweenInfo = TweenInfo.new(FOVTransitionTime, Enum.EasingStyle.Linear)
local fovTween = TweenService:Create(camera, tweenInfo, { FieldOfView = fov })
fovTween:Play()
end
local lastMoveDirection = Vector3.new(0, 0, 0)
local isMoving = false
while true do
wait()
local moveDirection = humanoid.MoveDirection
if moveDirection == Vector3.new(0, 0, 0) then
if isMoving then
setFOV(InitialFOV)
isMoving = false
end
else
if not isMoving then
isMoving = true
setFOV(MaxFOV)
end
humanoid.WalkSpeed = math.min(humanoid.WalkSpeed + 0.8, MaxSpeed)
end
if moveDirection ~= lastMoveDirection then
lastMoveDirection = moveDirection
end
end
Video of the issue: