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

How to detect middle mouse button?

Asked by 6 years ago

I have code that breaks a weld from the player:

01local ReplicatedStorage = game:GetService("ReplicatedStorage")
02 
03local createPartEvent = ReplicatedStorage:WaitForChild("CreatePartEvent")
04 
05   
06 
07local player = game.Players.LocalPlayer
08 
09local mouse = player:GetMouse()
10 
11   
12 
13   
14 
15   
16 
17mouse.Button3Down:Connect(function()
18 
19if game.workspace.Values.have.Value == 1 then
20 
21game.workspace.Values.have.Value = 0
22 
23createPartEvent:FireServer()
24 
25player.Character.Weld:Destroy()
26 
27end
28 
29end)

I put button3down, it is wrong. How do you detect it??

0
I believe it was called MiddleMouseButton, I'm not sure though LordTechet 53 — 6y
0
No it's not, it has to do something with user input. User#25281 0 — 6y
0
First of all, use the UserInputService for receving input. You can do "if UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton3) then`. DeceptiveCaster 3761 — 6y
0
then"* DeceptiveCaster 3761 — 6y
View all comments (6 more)
0
That didn't work User#25281 0 — 6y
0
Okay, use the InputBegan event and define a parameter named input. Then find if the UserInputType of the input was MouseButton3, then continue. DeceptiveCaster 3761 — 6y
0
theres a .WheelForward event and a .WheelBackward event, but those fire if you roll the wheel not click it, so there's surely an Enum for the Middlebutton starmaq 1290 — 6y
0
ok Found it, it's called "MouseWheel", try that starmaq 1290 — 6y
0
i don't have a mouse to test this xd xd so rip starmaq 1290 — 6y

1 answer

Log in to vote
1
Answered by
Lucke0051 165
6 years ago
Edited 6 years ago
01    local UIS = game:GetService("UserInputService")
02 
03   
04 
05UIS.InputBegan:Connect(function(key)
06 
07if key.UserInputType == Enum.UserInputType.MouseButton3 then
08 
09--code here
10 
11end
12 
13end)
Ad

Answer this question