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

SelectionGained

This event fires when the Gamepad selector starts focusing on the GuiObject.

If you want to check from the Gamepad select stops focusing on the GUI element, you can use the GuiObject/SelectionLost event.

When a GUI gains selection focus, the value of the GuiService/SelectionObject|SelectionObject property also changes to the that gains selection. To determine which GUI gained selection, check the value of this property.


Code Samples


Handling GUI Selection Gained

The following example prints a message when the user selects the object with a gamepad.

In order for this to work as expected, it must be placed in a LocalScript and a child of gui.

local gui = script.Parent

local function selectionGained()
	print("The user has selected this button with a gamepad.")
end

GuiObject.SelectionGained:Connect(selectionGained)