I have a tween in my game for field of view, but after the tween is completed, the field of view snaps back into the default FOV.
How can I solve this? I tried manually setting the FOV after the tween completes but it still returns to the default FOV.
Code:
local plr = game:GetService("Players").LocalPlayer
local cam = workspace.CurrentCamera
local TS = game:GetService("TweenService")
local CAS = game:GetService("ContextActionService");
local tutCams = workspace.TutorialCameras
local StarterGui = game:GetService("StarterGui")
local RS = game:GetService("RunService")
local black = script.Parent.Black
function changeFOV(fov, length)
local fovGoal = {}
fovGoal.FieldOfView = fov
local tweenInfo = TweenInfo.new(length,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
local fovChange = TS:Create(cam,tweenInfo,fovGoal)
return fovChange
end
local tInfo = TweenInfo.new(
4,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
function tweenCam(p1, p2, length, style, direction)
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = p1.CFrame
local Goal = {}
Goal.CFrame = p2.CFrame
local tweenInfo = TweenInfo.new(length,style,direction)
local change = TS:Create(cam,tweenInfo,Goal)
change:Play()
end
wait(1)
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = tutCams.Cam1A.CFrame
wait(5)
for i = 0, 1, 0.01 do
black.BackgroundTransparency = i
RS.RenderStepped:Wait()
end
wait(1)
tweenCam(tutCams.Cam1A,tutCams.Cam1B, 4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local fieldview = changeFOV(20, 4)
fieldview:Play()