Mouse Scroll acting weird for custom camera

So, I have a recreation of the roblox studio camera. It’s pretty good, but zooming into a position when scrolling is a problem. It always seems to build up instead of being set.

Normal camera (studio):

Recreation camera:

Does anyone know how to fix this?
Code:

uis.InputChanged:Connect(function(inp, gp)
		if inp.UserInputType == Enum.UserInputType.MouseWheel and not gp then
			local loc = uis:GetMouseLocation()
			local ray = cam:ViewportPointToRay(loc.X, loc.Y)
			local direction = (inp.Position.Y/math.abs(inp.Position.Y))
			cam.CFrame = CFrame.lookAt(cam.CFrame.Position, ray.Origin + ray.Direction * 1000)
			cam.CFrame *= CFrame.new(0,0,-self.mouse_wheel * direction) -- mouse_wheel is 15
		end
	end)
1 Like

You probably want to decrease the 1,000 scalar you’re multiplying with.

You might wanna mess with this

Does no difference, i changed it to 10. I think i have a solution, however. I will try it and send results.

Didn’t work, damn. Welp, that sucks