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

How to detect middle mouse button?

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??

10 comments

0

I believe it was called MiddleMouseButton, I'm not sure though

0

No it's not, it has to do something with user input.

0

First of all, use the UserInputService for receving input. You can do "if UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton3) then`.

0

then"*

0

That didn't work

0

Okay, use the InputBegan event and define a parameter named input. Then find if the UserInputType of the input was MouseButton3, then continue.

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

0

ok Found it, it's called "MouseWheel", try that

0

i don't have a mouse to test this xd xd so rip

1 answer

✓ Accepted answer
    local UIS = game:GetService("UserInputService")

  

UIS.InputBegan:Connect(function(key)

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

--code here

end

end)

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