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?
✓ ANSWER ACCEPTED
I need help when I scroll a mouse, to do a code, any idea?
1 answer
✓ Accepted answer
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
t o d o a c o d e
for example, if you scroll, then it prints something