I'm trying to get the Camera to smoothly move from one place to another, I figured I could do this with CFrame. So I set up a loop with RenderStepped (The script is local) and found that the Camera reached the end CFrame before Frame actually was 1
local RunService = game:GetService("RunService") local Camera = game.Workspace.CurrentCamera Camera.CameraType = "Scriptable" Frame = 0 EndFrame = CFrame.new(-69.241951, 97.460762, 49.9143524, -0.508211434, 0.107174382, -0.854537845, -0, 0.992226899, 0.124443039, 0.86123246, 0.0632433742, -0.504260957) --I used the command console to print out the Camera's CFrame from where I wanted it Loop = RunService.RenderStepped:connect(function() if Frame >= 1 then Loop:Disconnect() end Frame = Frame + .01 Camera.CFrame = Camera.CFrame:lerp(EndFrame, Frame) print(Frame) end)
I'm confused on how you're assuming the Frame will equal 1 at the exact same time the CFrame reaches the end CFrame.
Answer
I believe the correct thing to do would be using lerp's
already given time duration function. Which is the 3rd argument of lerp.
So instead your code would be
Camera.CFrame = Camera.CFrame:lerp(EndFrame, Frame,1)--Reaches the end CFrame in one second.
If this helped, please accept and let me know.