Roblox Input
When to Load
Handling touch, gamepad, keyboard/mouse or TV-remote input: binds, on-screen action buttons, cancel paths, button hints. Layout, safe areas, touch-button placement from TouchGui and gamepad focus graphs: roblox-ui (§1, §2); aim and shoulder cameras: roblox-camera; sending input to the server: roblox-networking.
"Field case" = seen in one of the owner's projects; verify on your content.
Traps and review checklist (symptom -> cause -> fix)
- Key bind does nothing or opens a Roblox panel -> it collides with a default bind. Always reserved: Esc/
ButtonStart(Roblox menu), F9, F11, F12, PrintScreen. Reserved unless you disable the feature:/chat, Tab player list (CoreGuiType.PlayerList), backquote backpack, 0-9 tool equip, Backspace drop tool,\UI selection, Shift mouse lock (EnableMouseLockOption); gamepadButtonL1/ButtonR1swap tools,ButtonR2uses the tool,ButtonSelectUI selection. Never put a core feature on backquote (missing on many layouts), and every keyboard-opened panel also needs a tap button for touch (field case) (§1). - Interactive
SurfaceGuibuttons ignore clicks -> theSurfaceGuimust live underPlayerGui(Adornee= the part), and the adorned part needsCanQuery = true, or input never reaches the button. Mounting it right is not enough if the sign part isCanQuery = false. - Cursor trapped in a menu in first person / shift-lock -> a visible
GuiButtonwithModal = trueoverridesMouseBehavior(unless right mouse is held), but the icon can stay hidden and per-frame camera code re-locks it. SetMouseIconEnabled = truetoo, drive both from one "any menu open" state that the camera code also reads (per-screen mouse code left invisible cursors and locked cameras, field case, repeated), restore on close, and close with a key and gamepad B (§1). - Clicks dropped near a proximity prompt in a locked-mouse game ->
ClickablePrompt = true(default) puts the prompt button under the centred cursor; it sinksMouseButton1(gameProcessedEvent = true) and drops held actions (field case). SetClickablePrompt = falsewhen the prompt is created (inPromptShownwas too late); tap still works on mobile per the docs. - Touch buttons show on a PC, or stay after plugging in a pad -> layout picked once from
TouchEnabled. Show controls fromUserInputService.PreferredInputand re-run onGetPropertyChangedSignal("PreferredInput").GetLastInputType()flips on every input and reportsFocuson window focus; don't drive layout from it. - TV remote not detected ->
Enum.PreferredInput.MicroGamepadexists but is not set yet for these devices . CheckGamepad1connected andGamepadSupportsfalse for bothThumbstick1andThumbstick2(ButtonCentertoo for a TV remote). Never detect by keycode: centre arrives asButtonA, back asButtonB, arrows as D-pad in menus butThumbstick1/Thumbstick2in gameplay, same as a full pad. - Controller stuck in a menu -> the gamepad button that opened the menu is still bound and swallows navigation. Menu binds must
Pass(or their context be disabled) while any window is open; the D-pad that opened a window can't close it (it moves focus there), so close with B. Third-party top-bar libraries may listen on rawInputBeganfor D-pad Up. Focus graph:roblox-ui§2. - Attack fires under a menu, or jump dead after closing one on gamepad -> gate every gameplay handler on one check:
gameProcessedEvent,GetFocusedTextBox() == nil,not GuiService.MenuIsOpen,GuiService.SelectedObject == nil, no game window open. CAS handlers get nogameProcessedEvent. - Charged throw fires when the player cancelled -> cancel is not release. Cancel (never complete) on
UserInputState.Cancel, window open, unequip/death,WindowFocusReleased, aPreferredInputchange, orGamepadDisconnectedof the pad that started the hold (poll that pad, notGamepad1). CAS deliversEnd/Cancel(and touch-button input) withKeyCode.Unknown: branch on state before any keycode filter. - Gamepad R2 stopped firing the tool ->
Tool.ManualActivationOnly = truealso kills theBindActivateroute the default controls use forButtonR2. Set it fromPreferredInput, notTouchEnabled. - Gamepad/touch shots go to a stale point -> aim code reads
GetMouseLocation(). WithPreferredInputnotKeyboardAndMouseor the mouse locked, aim from the viewport centre and show the reticle (roblox-camera). - Wrong glyph or "Press 1" on console -> hardcoded key names. Use
GetStringForKeyCode(key, Enum.KeyCodeStringFormat.Abbreviated)/GetImageForKeyCode(key)(separate PlayStation and Xbox image sets; Studio emulation returned PlayStation in a field case) orInputActionLabel; refresh onPreferredInputchange, including tooltips and tutorial text. Hotbar cycles onButtonL1/ButtonR1, not number hints. - Feels like auto-fire -> presses refused during cooldown are queued. Act only on a press that arrives when ready; clear the queued flag on every refused press.
- Gadget runs forever after equip -> hold-to-run is a toggle on touch/gamepad (correct: the thumb also steers) but a trigger already down at equip lands its release in the toggle path. Clear the held flag on equip and unequip.
- Move vector reads nothing ->
Workspace.PlayerScriptsUseInputActionSystem(Studio property) makes the default controls run through input actions; code requiringPlayerScripts.PlayerModulefor the move vector gets nothing. Read the movementInputAction.
What changed
| Change | Use now |
|---|---|
ContextActionService:BindAction and related binds "planned for deprecation" |
Input Action System: InputContext > InputAction > InputBinding instances (key, pad, UIButton). Keep old CAS code, migrate on touch |
InputAction:Fire() deprecated |
InputBinding:Fire(state) on a binding with Type = Scriptable; silently ignored if the action or its context is disabled; errors on a type mismatch |
PreferredInput (KeyboardAndMouse, Gamepad, Touch, MicroGamepad) |
Present controls from it; InputAction.PreferredBinding gives the matching binding |
InputActionLabel, Input Action Manager (Window > Input): beta |
Label shows the live key/icon for an action; Manager flags missing (yellow) and duplicate (red) bindings |
| Server Authority | Simulation input through the IAS, processed in RunService:BindToSimulation() (needs Workspace.UseFixedSimulation), not a RemoteEvent stream |
1. Menus and keys
- Every clickable popup needs a key on PC: with the cursor locked centre, a mid-game vote can't be clicked. Route popups through a key players know; phones tap.
- Bag/inventory on PC: pick a key outside the reserved list above (for example
B,I), or disable the player list / backpack (StarterGui:SetCoreGuiEnabled) before taking Tab or backquote. - Menu blocking in the IAS: enable a higher-
PriorityInputContextwithSinkthat binds the gameplay keys while the menu is open; rawUserInputServicehandlers still need the gate above.
2. Testing
Built-in Studio MCP: user_keyboard_input, user_mouse_input, character_navigation and the rbx-device-simulator-lua skill (roblox-studio-mcp). Per feature: controller-only cold join; tap, hold, release and cancel (open a window, the Roblox menu, unplug the pad mid-hold: nothing fires); drag the camera across every touch button; switch touch -> gamepad -> mouse without respawning; Xbox, PlayStation and TV Remote in Controller Emulator. The simulator doesn't reproduce console system overlays or thumb reach: test those on hardware.
