Getting the Target Zoom Distance

One issue commonly run into when when working with the default Roblox zoom is getting the target zoom distance accurately. There is one common solution, getting the distance between the camera and head, though it runs into the issue of returning the wrong value when the ideal path of the camera is blocked by an object.

The best solution to this issue is to fork the Roblox PlayerModule and adjust the ZoomController to save the target zoom level to a variable of your choosing, in my case this being an attribute under the player.

To do this, simply:
1. Run the game, and copy the module script titled “PlayerModule” following the path Players > Your player object > PlayerScripts > PlayerModule
2. End the testing session and paste the PlayerModule script that you copied into StarterPlayer > StarterPlayerScripts
3. Open up the ZoomController module script following the path PlayerModule > CameraModule > ZoomController
4. Navigate down to the function on line 126 labeled SetZoomParameters
5. Add a line of code in that function to save the targetZoom variable to a spot of your choice

Hope this helps someone trying to work with the zoom!

1 Like