PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

MouseButton1Up

The MouseButton1Up event fires when the user releases their left Mouse up off of the GUI object.

This event is similar to GuiButton/MouseButton2Up, which behaves identically except that it is connected to the user’s right mouse button.

If you are looking for an event requiring the user to press and release their left mouse on a GUI in order for the event to fire, consider using GuiButton/MouseButton1Click.

Note that this event will only fire for GUI buttons, including TextButton|TextButtons and ImageButton|ImageButton. It will not fire for other GuiObject|GuiObjects.

Parameters

Name Type Default Description

x

int

The mouse’s x screen coordinate in pixels

y

int

The mouse’s y screen coordinate in pixels


Code Samples


Handling Right Mouse Button Up/Down on a GUI Button

The code sample below demonstrates how to use the GuiButton/MouseButton1Up and GuiButton/MouseButton1Down events to handle user input when the left mouse button is pressed down and released up on a GuiButton.

For the example to work expected, the LocalScript containing the code should be a child of the GUI button.

function leftMouseButtonUp(x, y)
	print("Left mouse up")
end

function leftMouseButtonDown(x, y)
	print("Left mouse down")
end

script.Parent.MouseButton1Up:Connect(leftMouseButtonUp)
script.Parent.MouseButton1Down:Connect(leftMouseButtonDown)