Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to Tell if the Middle Mouse Button is Down?

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

✓ Accepted answer
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)

17 comments

0

can you refrain from copying me

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

0

highly doubt it

1

I didn't ask for your opinion, it doesn't take a rocket scientist to see the difference

0

what was the point of answering an already answer accepted question tho

1

what don't you understand about writing my answer before yours came out

1

Vulkarin is right.

0

heh not my fault you took a long time. also everyone says that

1

don't let your arrogance blind you

0

i'm not arrogant lol. i'm just saying you copied my idea

0

your script doesn't even work, lol

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

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

0

facepalm if it didn't work my answer wouldn't have been accepted lol. whose the smartie now

0

my answer must be right if it was accepted "i'm not arrogant"

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.

0

it's like saying your smart when the teacher accepts your answer of 1+1 is 3 lol

You cant. It is actually refered to as

WheelBackward

or

WheelFoward

eg.

if WheelBackward:connect(function()
	-- script goes here
end

3 comments

0

No.

0

You will get an error on that last code snippet.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.