MouseEnter
The MouseEnter event fires when a user moves their mouse into 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 enters a GUI. These coordinates may vary even when the mouse enters the GUI via the same edge - particularly when the mouse enters 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 enters the GUI.
This event fires even when the GUI element renders beneath another element.
If you would like to track when a user’s mouse leaves a GUI element, you can use the GuiObject/MouseLeave event.
See also
GuiObject/MouseLeaveGuiObject/MouseMovedGuiObject/MouseWheelForwardGuiObject/MouseWheelBackward
Parameters
| 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
GuiObject.MouseEnter
The following example prints the mouse location, in pixels, when it enters GUI element.
GuiObject.MouseEnter:connect(function(x, y)
print("The user's mouse cursor has entered the GuiObject at position (" .. x .. ", " .. y .. ").")
end)