Can someone help me if I scroll a mouse forward, it does the code, but when I scroll mouse back, then it does another type of code. Any ideas, please?
You can achieve this with UserInputService
. Here's an example.
UserInputService
has an event called InputChanged
that also fires when the mouse wheel is scrolled.
local InputService = game:GetService("UserInputService") local Forward = function() print("The mouse was scrolled forward!") -- Do a code end local Backward = function() print("The mouse was scrolled backward!") -- Do a code end InputService.InputChanged:Connect(function(Input) if Input.UserInputType == Enum.UserInputType.MouseWheel then local Direction = Input.Position.Z if Direction == 1 then Forward() elseif Direction == -1 then Backward() end end end)
Closed as Not Constructive by Gameplayer365247v2, User#23252, and xPolarium
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?