how to detetc pc xbox and playstation on roblox
Quick Scoop
To detect PC vs Xbox vs PlayStation in Roblox, the most reliable approach
is usually to check the player’s input type, not try to read the exact console
model directly. Roblox DevForum guidance says
UserInputService.GamepadEnabled only tells you that a gamepad is active, and
GetStringForKeyCode(Enum.KeyCode.ButtonA) can help distinguish Xbox from
PlayStation because it returns different button names like ButtonA or
ButtonCross depending on the controller mapping.
How it works
- PC:
KeyboardEnabledis often true, andGamepadEnabledmay be false unless a controller is connected.
- Xbox / PlayStation:
GamepadEnabledbecomes true, but that alone does not tell you which console it is.
- Xbox vs PlayStation: a common community method is checking what
GetStringForKeyCode(Enum.KeyCode.ButtonA)returns, then mappingButtonAto Xbox andButtonCrossto PlayStation.
Simple Lua example
lua
local UIS = game:GetService("UserInputService")
local function getDeviceType()
if UIS.KeyboardEnabled then
return "PC"
end
if UIS.GamepadEnabled then
local buttonAName = UIS:GetStringForKeyCode(Enum.KeyCode.ButtonA)
if buttonAName == "ButtonCross" then
return "PlayStation"
elseif buttonAName == "ButtonA" then
return "Xbox"
end
return "Controller"
end
return "Unknown"
end
print(getDeviceType())
This kind of logic is mainly useful for showing the right button icons or UI prompts, since Roblox developers note there is no fully official, guaranteed platform detector for Xbox vs PlayStation.
Important limits
- A controller connected to a PC can look similar to a console input, so input detection is safer than assuming platform.
GamepadEnabledmeans “a gamepad is present,” not “this is definitely Xbox.”
- For best results, many developers update UI based on the player’s current input mode rather than trying to hard-detect the device itself.
Practical use
If your goal is button prompts, do this:
- Detect keyboard, touch, or gamepad input.
- If gamepad is used, check the mapped button name to choose Xbox or PlayStation icons.
- Fall back to generic controller UI if the mapping is unclear.
TL;DR
Use KeyboardEnabled for PC-style input, GamepadEnabled for controller
input, and GetStringForKeyCode(Enum.KeyCode.ButtonA) to separate Xbox from
PlayStation in many cases.