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 5 years ago

I have code that breaks a weld from the player:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local createPartEvent = ReplicatedStorage:WaitForChild("CreatePartEvent")



local player = game.Players.LocalPlayer

local mouse = player:GetMouse()







mouse.Button3Down:Connect(function()

if game.workspace.Values.have.Value == 1 then

game.workspace.Values.have.Value = 0

createPartEvent:FireServer()

player.Character.Weld:Destroy()

end

end)

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 — 5y
0
No it's not, it has to do something with user input. User#25281 0 — 5y
0
First of all, use the UserInputService for receving input. You can do "if UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton3) then`. DeceptiveCaster 3761 — 5y
0
then"* DeceptiveCaster 3761 — 5y
View all comments (6 more)
0
That didn't work User#25281 0 — 5y
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 — 5y
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 — 5y
0
ok Found it, it's called "MouseWheel", try that starmaq 1290 — 5y
0
i don't have a mouse to test this xd xd so rip starmaq 1290 — 5y

1 answer

Log in to vote
1
Answered by
Lucke0051 165
5 years ago
Edited 5 years ago
    local UIS = game:GetService("UserInputService")



UIS.InputBegan:Connect(function(key)

if key.UserInputType == Enum.UserInputType.MouseButton3 then

--code here

end

end)
Ad

Answer this question