Collapse Sidebar


The MouseLeave event fires when a user moves their mouse out of a GuiObject|GUI element.

Please do not rely on the x and y arguments passed by this event as a fool-proof way to to determine where the user’s mouse is when it leaves a GUI. These coordinates may vary even when the mouse leaves the GUI via the same edge - particularly when the mouse leaves the element quickly. This is due to the fact the coordinates indicate the position of the mouse when the event fires rather than the exact moment the mouse leaves the GUI.

This event fires even when the GUI element renders beneath another element.

See also

  • GuiObject/MouseEnter
  • GuiObject/MouseMoved
  • GuiObject/MouseWheelForward
  • GuiObject/MouseWheelBackward


Name Type Default Description



The mouse’s x screen coordinate in pixels, relative to the top left corner of the screen



The mouse’s y screen coordinate in pixels, relative to the top left corner of the screen

Code Samples

Drawing Canvas GUI

The code sample below creates a GUI Frame that acts as a canvas that can be drawn on and cleared.

It uses two UserInputService events, UserInputService/InputBegan and UserInputService/InputEnded to determine when the user’s left mouse button is down. These events set the hold variable so that the paint function only draws a new pixel if the user’s left mouse button is pressed.

When the user’s mouse moves on the canvas, the pointer GUI moves to follow the mouse and, if the hold is true, clones the pointer to draw a new pixel onto the canvas at the pointer’s location. The pointer’s visibility is set to false when the mouse exits the GUI and to true when the mouse enters the GUI.

Pressing the clear button destroys all Canvas children named “Pixel” to clear the canvas.

Canvas GUI Demonstration

Gui in Studio Explorer