Scroll FOV changer

Hey Dev!

Hey guys I wondering how I can make a script that when it detects the player scrolling is wheel forward the FOV Decreases which makes the camera zoom in , and when he scrolls back it increases which makes the camera zoom out, I’ve got the basic script down but I need help with adding on to FieldOfView.

Current Code:


mouse.WheelForward:connect(function()
	print("Zooming In")

end)

mouse.WheelBackward:Connect(function()
	print("Zooming Out")

end)

Any Feedback and help is loved! :heart:

1 Like
local increment = 1 -- example
mouse.WheelForward:connect(function()
	print("Zooming In")
	workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView - increment
end)

mouse.WheelBackward:Connect(function()
	print("Zooming Out")
	workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView + increment
end)

You will get a warning if you scroll forward/backward too much, but Roblox can handle it. You can get rid of that message with some checks, but it is not necessary.

2 Likes

Thanks ill try this out, thanks for the help!

2 Likes