I've been trying to lerp CurrentCamera.FieldOfView from 70 to 100, but nothing i have found helped me, Lerp,Tween,Interpolate, i can't figure out what i am doing wrong, this is the base script:
repeat wait() until workspace.CurrentCamera local cam = workspace.CurrentCamera local fov = cam.FieldOfView DefaultFov = 70 MaxFov = 100
I want to figure out how to interpolate those values from 70 to 100 without returning any value like 70.8, 79.06,etc... Is there a correct way to do that?
Ok, so firstly, the camera's FieldOfView is a float
meaning it will likely never be exactly an integer: https://developer.roblox.com/api-reference/property/Camera/FieldOfView
However, you can alter the FieldOfView by integer increments using a for-loop.
Revised Local Script Example
repeat wait() until workspace.CurrentCamera ~= nil local cam = workspace.CurrentCamera for f = 70, 100, 1 do cam.FieldOfView = f wait() end
If you need to print an integer or have a function that requires the value of FOV to be an integer, you can use the functions math.floor() -- Round Down, or math.ceil() -- Round Up on the FieldOf View in your code.
print(math.floor(cam.FieldOfView)) print(math.ceil(cam.FieldOfView))
If you need to make sure the value of FieldOfView cannot surpass 100, you can also use these functions, or use math.clamp() as is explained in the link below.