Zoom not working in game

So I have 2 functions (both deprecated, IK) and they work in Roblox Studio but on the regular game launched on the website or the app the only function that works is the wheelforward function. The functions look like this:

function WheelForward()
	if AimingIn == true then
		if Debounce == true then
			Debounce = false
			print("Forward")
			if Camera.FieldOfView == 70 then
				for i = 1, 10 do
					Camera.FieldOfView = Camera.FieldOfView - 1
					wait()
				end
				game.Lighting.DOF.FarIntensity = 0.215
				game.Lighting.DOF.NearIntensity = 0.215
				Camera.FieldOfView = 60
			end
			Debounce = true
		end
	end
end

function WheelBackward()
	if AimingIn == true then
		if Debounce == true then
			Debounce = false
			print("Backward")
			if Camera.FieldOfView == 60 then
				for i = 1, 10 do
					Camera.FieldOfView = Camera.FieldOfView + 1
					wait()
				end
				game.Lighting.DOF.FarIntensity = 0.1
				game.Lighting.DOF.NearIntensity = 0.35
				Camera.FieldOfView = 70
			end
			Debounce = true
		end
	end
end

“Camera” is workspace.CurrentCamera btw.
I have figured out why it’s not working… kind of. What happens is when I’m scrolling forward it works but when I scroll backward after I scroll forwards it just prints, I think it’s something to do with the if statement but I don’t know why, the FOV is 50 when I scroll backward, just like it is when I scroll forward.

Just if you want to know; the functions get called in an Equipped function/event with the mouse from the function/event.

Instead of

if Camera.FieldOfView == 60 then

use

if Camera.FieldOfView <= 60 then

see if this helps

Still didn’t do anything. :frowning: Like I said, it only works in studio but when I’m in proper game it doesn’t work properly.

Try adding a print Statement to the if Statement if it prints then its not the if Statement its something to do with the code inside

It’s the if statement, I put a print right after the if statement and it didn’t print anything, WheelForward is still the only function working properly.

try printing Camera.FieldOfView right before the if Statement

if the Camera.FieldOfView isnt exactly 60 the if Statement wont Parse

1 Like

3bada82b499e770db57e33b84aeb31fe
It wasn’t working because it wasn’t EQUAL TO 50. Thanks!