You can just get the velocity of the HumanoidRootPart for the current speed. I’m going to also lerp the values so that it doesn’t feel unnatural (or change values too fast).
local PS = game:GetService("Players")
local RNS = game:GetService("RunService")
local player = PS.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local HRP: BasePart = char:WaitForChild("HumanoidRootPart")
local camera = workspace.CurrentCamera
local divisor = 5 -- the dampening of the dynamic fov
local lastVelocity = HRP.AssemblyLinearVelocity.Magnitude / divisor
local defFov = 70
local function Lerp(a, b, t)
return a + (b - a) * t
end
RNS.RenderStepped:Connect(function()
camera.FieldOfView = defFov + Lerp(lastVelocity, HRP.AssemblyLinearVelocity.Magnitude / divisor, .25)
lastVelocity = camera.FieldOfView - defFov
end)