Hey, I've been trying to get this to work for hours, I've tried googling but there wasn't much help there. I'm trying to make it run a function when I press the mouse WHEEL button, however, the script isn't working properly, instead of it working when I press the MOUSE WHEEL BUTTON, it works with EVERY button on my keyboard.
Here is the code I'm working with so far, 0 errors just doesn't work like I wan't it to.
local UIS = game:GetService("UserInputService") function randomfunction() print("test") end UIS.InputBegan:connect(function() randomfunction() end)
Can someone teach me how to use the Mouse Wheel Button in a script?
Thanks
~Rafael
local UIS = game:GetService("UserInputService") function randomfunction() print("test") end UIS.InputBegan:connect(function() If input.UserInputType == Enum.UserInputType.MouseButton3 then -- Notice randomfunction() end end)
You forgot to add a conditional statement to make sure that only input of the MouseButton3 type (middle wheel) triggers the function.
Hope this helped.