Development / ROBLOX
Switch Roblox control hints with PreferredInput
Give one action keyboard, touch, and gamepad hints, then test device changes without leaving the game.
Separate the action from its hint #
Choose a harmless action such as opening a map. Keep one function that opens it and show a hint beside the control. When the hint changes from a keycap to a controller button, the map action stays the same. This makes a wrong image easier to distinguish from a binding that actually fails.
Read PreferredInput on the client #
Read UserInputService.PreferredInput from a client script when the interface first appears. It describes the preferred input, rather than being a list of connected devices. A PC with a controller plugged in may still need mouse and keyboard hints after the player returns to those controls.
Render once and subscribe to changes #
Connect GetPropertyChangedSignal("PreferredInput") and read the property again whenever the signal fires. Call the same render function immediately after connecting so the first hint appears before any device switch. A change listener on its own can leave the first screen blank until interaction occurs.
Keep a fallback label #
Map Touch, Gamepad and KeyboardAndMouse to appropriate labels and icons. If the matching icon is missing, show a short action label so the control is still understandable. Changing a hint need not remove an available touch control or change native Roblox bindings.
Test changes in both directions #
Open the map with a keyboard, use the controller, then return to the mouse without ending the test. On a tablet, compare touch and a connected controller. Record the hint after each input change and confirm that one activation opens the map once.
Avoid duplicate listeners when a menu reopens #
Open and close the UI several times. If every opening adds another listener, a device change can render the hint repeatedly. Connect once for the UI's lifetime or disconnect the old listener when it is destroyed. Repeat the initial render and device switch after respawn.
| What to check | Expected result |
|---|---|
| Action | One function |
| Preferred input | Current hint |
| First render | Hint appears |
| Icon missing | Show the action label |
| Switch devices | Key and gamepad |
| Reopen UI | One listener |
Original sources
Roblox Creator Hub · Input overviewRoblox Creator Hub · UserInputService
Roblox Creator Hub · Gamepad input


