So what this does is it calculates the distance needed for the dolly zoom effect with the cameras field of view being inputted. However, I want to input the distance instead of the FOV. So like how would I get it to give me the required FOV instead?
You can calculate the required FOV for a given distance and width using the inverse tangent function (atan). The formula would be:
FOV = 2 * atan(width / (2 * distance))
local FOV = 2 * math.deg(math.atan(width / (2 * dist)))