Hi guys, I have a camera script that works fine, but it lags really bad at lower frame rates. How can I use deltaTime to stop the choppiness?
local RunService = game:GetService("RunService")
local car = script.Parent.Car.Value
local cam = workspace.CurrentCamera
-- if offset is too far on one side, change the offset value
-- -1.5 for right hand drive and 1.5 for left hand drive
cam.CameraType = "Scriptable"
cam.FieldOfView = 50
RunService:BindToRenderStep("CustomCam", Enum.RenderPriority.Camera.Value + 1, function(deltaTime)
local carSpeed = car.DriveSeat.Velocity.Magnitude
local smoothness = 1000 / (carSpeed / 10)
local pos = car.DriveSeat.CFrame * CFrame.new(1.5, 6, 24) * CFrame.Angles(-math.rad(8), 0, 0)
cam.CFrame = cam.CFrame:Lerp(pos, 0.25)
if carSpeed > 85 then
cam.CFrame = cam.CFrame * CFrame.new(math.random(-1, 1) / smoothness, math.random(-1, 1) / smoothness, math.random(-1, 1) / smoothness)
end
end)