The MouseButton2Down event fires when the user presses their left
Mouse button down on the GUI object.
This event is similar to
GuiButton/MouseButton1Down, which behaves identically except that it is connected to the user’s left mouse button.
If you are looking for an event requiring the user to press and release their right mouse on a GUI in order for the event to fire, consider using
Note that this event will only fire for GUI buttons, including
ImageButton|ImageButton. It will not fire for other
The mouse’s x screen coordinate in pixels
The mouse’s y screen coordinate in pixels
Handling Left Mouse Button Up/Down on a GUI Button
The code sample below demonstrates how to use the
GuiButton/MouseButton2Down events to handle user input when the right mouse button is pressed down and released up on a
For the example to work expected, the
LocalScript containing the code should be a child of the GUI button.
function rightMouseButtonUp(x, y) print("Right mouse up") end function rightMouseButtonDown(x, y) print("Right mouse down") end script.Parent.MouseButton2Up:Connect(rightMouseButtonUp) script.Parent.MouseButton2Down:Connect(rightMouseButtonDown)