Collapse Sidebar




This property sets the GuiObject|GUI selected when the user moves the Gamepad selector to the right. If this property is left blank, the moving the Gamepad right will not change which selected GUI.

Moving the Gamepad selector right sets the GuiService/SelectedObject to this object unless the GUI is not GuiObject/Selectable|Selectable. If the GUI is not selectable, it will not be selected when the gamepad selected moves right.

Note that since this property can be set to a GUI element even if it is not Selectable, you should ensure that the value of a GUI’s selectable property matching your expected behavior.

See also

  • GuiObject/NextSelectionUp
  • GuiObject/NextSelectionDown
  • GuiObject/NextSelectionLeft

Code Samples

Creating a Gamepad Selection Grid

This example demonstrates how to enable Gamepad navigation through a grid of GuiObject|GUI elements without manually having to connect the GuiObject/NextSelectionUp, GuiObject/NextSelectionDown, and GuiObject|NextSelectionRight, and GuiObject/NextSelectionLeft properties for every element in the grid.

Note that this code sample assumes your UIGridLayout is sorted by UIGridLayout/SortOrder|name, where elements are named in successive numerical order (see image below).

UIGridLayout Sorted By Name

The code relies on this to set the NextSelection properties for all GuiObjects in the same level as the UIGridLayout. In our example, the UIGridLayoutObject and GUI elements within the grid are all children of a Frame named “Container”. The code Instance/GetChildren|gets the children of “Container” and loops through each child. Children that are not GuiObjects are ignored. For each GUI element, the code attempts to assigned the NextSelection properties using the following logic:

  1. Starting with 1, the name of all GUI elements match their position in the grid
  2. Left: The item to the left will always be numbered 1 less than the current element
  3. Right: The item to the left will always be numbered 1 more than the current element
  4. Up: The item above (up) will always be number of GUIs in a row 1 less than the current element
  5. Down: The item below (down) will always be the number of GUIs in a row more than the current element
    This logic also allows for the GUI elements at the begging and end of rows (excluding the first and last element) to wrap around to the next and previous rows. If an element doesn’t exist to the left, right, up, or down, the NextSelection will remain nil and moving the Gamepad selector in the direction will not change the selected GUI.

This example also contains code to test the grid using the arrow keys (Up, Down, Left, Right) of your keyboard instead of a gamepad, just in case you don’t have a gamepad to test with. This portion of code initially selects the element named “1” by assigning it to the GuiService/SelectedObject property.

Grid Demonstration Gif