Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to Tell if the Middle Mouse Button is Down?

Asked by
INOOBE_YT 387 Moderation Voter
6 years ago

There isn't any way to tell if the middle mouse button is down, only the left/right buttons. Is there any way to tell if it is down? I tried InputBegan, but that returned Enum.KeyCode.Unknown. Maybe there is a different event that returns the middle mouse button status?

2 answers

Log in to vote
1
Answered by
Vulkarin 581 Moderation Voter
6 years ago
local player = game:GetService("Players").LocalPlayer
local userinput = game:GetService("UserInputService")

userinput.InputBegan:Connect(function(input, bool)
    if bool then return end
    local input = input.UserInputType.Name
    if input == "MouseButton3" then
        print("MouseButton3 is being held down")
    end
end)
0
can you refrain from copying me User#19524 175 — 6y
1
lol I can't tell if you're joking or not, for one I started writing this before your answer came, and two my answer doesn't resemble your answer at all Vulkarin 581 — 6y
0
highly doubt it User#19524 175 — 6y
1
I didn't ask for your opinion, it doesn't take a rocket scientist to see the difference Vulkarin 581 — 6y
View all comments (13 more)
0
what was the point of answering an already answer accepted question tho User#19524 175 — 6y
1
what don't you understand about writing my answer before yours came out Vulkarin 581 — 6y
1
Vulkarin is right. AIphanium 124 — 6y
0
heh not my fault you took a long time. also everyone says that User#19524 175 — 6y
1
don't let your arrogance blind you Vulkarin 581 — 6y
0
i'm not arrogant lol. i'm just saying you copied my idea User#19524 175 — 6y
0
your script doesn't even work, lol Vulkarin 581 — 6y
0
it does though? the only difference between mine and yours is you defined the variables. OP will obviously have done that. and a different UserInputType maybe but it's the same thing User#19524 175 — 6y
0
needs the MouseButton3 input type which is literally what my whole thing is, and yet another reason why mine is not even remotely a copy, thanks Vulkarin 581 — 6y
0
*facepalm* if it didn't work my answer wouldn't have been accepted lol. whose the smartie now User#19524 175 — 6y
0
>my answer must be right if it was accepted "i'm not arrogant" Vulkarin 581 — 6y
0
not really it's just a fact. it's like saying i'm arrogant if my answer on a maths question that asked what 1 + 1 was is 2. User#19524 175 — 6y
0
it's like saying your smart when the teacher accepts your answer of 1+1 is 3 lol Vulkarin 581 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago

You cant. It is actually refered to as

WheelBackward

or

WheelFoward

eg.

if WheelBackward:connect(function()
    -- script goes here
end
0
No. User#19524 175 — 6y
0
You will get an error on that last code snippet. User#19524 175 — 6y
0
Thanks for the answer, but it's not what I am looking for. I am looking to detect it when the middle mouse button is clicked, not scrolled. INOOBE_YT 387 — 6y

Answer this question