Checking whether the mouse has been scrolled without using mouse.WheelForward

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to achieve to be able to catch the event when he mouse scrolls forwards and backwards by using an event in ContextActionService.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that I am trying to detect whether the wheel on the mouse is being scrolled, but Mouse.WheelForward or Mouse.WheelBack is quite basic, and if you were to open the chat menu and start scrolling, the event will still be caught in the code. I am looking for a scrolling wheel event in ContextActionService and I can’t find it.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    On Roblox Developer, it showed me the Mouse.WheelForward and Back events. It said for newer codes I should use something like ContextActionService but it did not tell me how to get the mousewheel in ContextActionService.

Try UserInputService | Documentation - Roblox Creator Hub.

game:GetService("UserInputService").InputChanged:Connect(function(input, gameProcessed)
    if gameProcessed then return end -- ignore chat window scrolling

    if input.UserInputType == Enum.UserInputType.MouseWheel then
        print("The mouse wheel has been scrolled!")
        print("Wheel Movement:",input.Position.Z)
    end
end)
1 Like

thank you about that. But I have some more questions; How exactly would I check if the wheel is scrolled up or down, and also will this error if a player on different platform than computer is using this event?

Check if input.Position.Z is positive or negative

It won’t error, but it probably wouldn’t do anything. A phone doesn’t have a mouse wheel, so I’m not sure what you expect it to do :slight_smile:

You could use ContextActionService | Documentation - Roblox Creator Hub instead if you want to bind multiple types of input to the same function.

thank you for the help. It is very appreciated.