How to detect what GUI element a player's mouse is over

Does anyone know how I can detect what GUI element a player’s mouse is hovering over?

I don’t know how I would be able to do this, because the MouseEnter function only works for a specific UI element.

But I can’t do this for a load of GUI elements that have been created by a script.

If you want an example, think of how Part:GetTouchingParts() works. Except its with the mouse, and UI elements instead of physical 3D objects

1 Like

PlayerGui:GetGuiObjectsAtPosition(x, y)

If you do the Player:GetMouse() you can use the mouse.X and mouse.Y coordinates to get the UI using it’s position.

3 Likes