How can I detect mouse wheel movement and determine direction?

I tried researching UserInputService some more, and I tried comparing input types, but I can’t seem to get my code to run :confused:

I’m trying to figure out how I can test if the player moved their mouse wheel, and also get the direction. (up or down.)

Thanks :slight_smile:

10 Likes

With the User input service you need to use InputChanged (not InputBegan) to detect mouse wheel movement and with the Z position of the input you can determine if the mouse wheel is being moved up or down. So for example:

 local UIS = game:GetService("UserInputService")

UIS.InputChanged:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseWheel then
		 if input.Position.Z > 0 then
			print("Mouse Wheel UP")		
	     	else
		   print("Mouse Wheel Down")		
		end
	end
end)
34 Likes