Custom scrolling frame system help

I am making a custom scrolling frame system. The only problem I have is that the camera is zooming when you scroll. Is there a way to prevent that?

This is the code responsible for scrolling:

frame.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseWheel then
        local canvasSize = (frame.CanvasSize.Y.Scale * frame.AbsoluteSize.Y) + frame.CanvasSize.Y.Offset
        local change = input.Position.Z * (attributes.ScrollSpeed or 50)
        local pos = Vector2.new(0, math.clamp(frame.CanvasPosition.Y - change, 0, canvasSize - frame.AbsoluteSize.Y))
    end
end)
2 Likes

Setting the Camera Type to Scriptable will prevent player’s camera from zooming in/out.

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

Just Change the CameraType when the Player is Scrolling,
And Change it Back to Enum.CameraType.Custom When Player Has Stopped Scrolling.

Your Code Should Be :

frame.InputChanged:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseWheel then
		workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
		local canvasSize = (frame.CanvasSize.Y.Scale * frame.AbsoluteSize.Y) + frame.CanvasSize.Y.Offset
		local change = input.Position.Z * (attributes.ScrollSpeed or 50)
		local pos = Vector2.new(0, math.clamp(frame.CanvasPosition.Y - change, 0, canvasSize - frame.AbsoluteSize.Y))
	else
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	end
end)
1 Like