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)
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)
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).