How do I make a smooth scroll to zoom system?

Hello, I would like to know how to make a smooth scroll to zoom system for my game!

I have been very confused lately on how to do it, I’ve tried Tweening it, and adding and subtracting the FOV it worked, but it wasn’t smooth.

Can anyone please help?

  • Here’s the code
connection2 = m.WheelForward:Connect(function()
							if cam.FieldOfView > 10 then
								if zoomTog == true then
									cam.FieldOfView = cam.FieldOfView - 1
									blurIn:Play()
									wait(0.25)
									blurOut:Play()
								end
							end
						end)

It doesn’t look like you are adding a debounce, and why don’t you tween the fov and blur

1 Like

Have you tried using the TweenService to tween the FOV value?

1 Like

I think you are looking for something similar to this?

UserInputService = game:GetService("UserInputService")
RunService = game:GetService("RunService")


local scrollSpeed = 1
local easeSpeed = .02
local fovTarget = 70
UserInputService.InputChanged:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseWheel then
		local up = input.Position.Z > 0 and 1 or -1
		
		fovTarget += up * scrollSpeed
	end
end)

RunService.Heartbeat:Connect(function()
	local camera = workspace:FindFirstChild("Camera")
	local fovCamera = camera.FieldOfView
	local fovDifference = fovTarget - fovCamera
	
	camera.FieldOfView += fovDifference * easeSpeed
end)

Here is a test place I set up for you to try this out:
Scroll Zoom System.rbxl (33.0 KB)

4 Likes

Yes, I have I just didn’t include it here.

I did, I just didn’t include it here.

  • scrollSpeed is unnessecary as you set it to just one

Use Tween Service.
If you’re looking for a mouse wheel input with a smooth zoom in, I recommend you using Tween Service to Tween FOV.
I Will link some tutorials below, if they’re any help to you let me know!
Links:

Well if you want the scrolling to be faster or slower you can change the scrollSpeed to 3 or 0.5 for example. Also useful if you have other modules that interact with these values (For example a Settings Module to adjust scrolling speed).