GetGuiObjectsAtPosition
For thread safety, this property is not safe to read in an unsynchronized thread.
This function takes a screen position and returns a list of all the visible GuiObject|GuiObjects that are occupying that screen position.
The main use case is to get GUI objects under the player’s mouse or touch inputs to do things like allow selection or highlighting. These effects can already be achieved using GuiObject/MouseEnter and GuiObject/MouseLeave but this requires the developer to track these events for their UI objects all the time even if they only need this functionality in specific circumstances.
Since the child classes of BasePlayerGui inherit this function, it can be fired by class objects such as the PlayerGui and StarterGui folders.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
The x position on the screen relative to the top left corner after the |
||
|
|
The y position on the screen relative to the top left corner after the |
Returns
| Return Type | Summary |
|---|---|
|
A table of the visible |
Code Samples
Selecting GUIs at a Position
All GUIs returned by GetGuiObjectsAtPosition() at ‘cloned’ by the highlighAsFrame() local function which creates a Frame GUI positioned on top of the specified GUI that is semi-transparent and the same GuiObject/AbsoluteSize and GuiObject/AbsolutePosition.
These highlights are added to the HighlightsContainer ScreenGui in the Highlight folder of the player’s PlayerGui folder. Both are created by the code sample. All highlight GUIs are Instance/Remove|Removed when every time highlightGui() executes.
Note that HighlightContainer’s ScreenGui/DisplayOrder is 99999, a large number, so that it is unlikely any other GUI will render on top of the higlight GUIs.