GetGamepadConnected
This function returns whether a gamepad with the given Enum/UserInputType
is connected to the client.
This can be used to check if a specific gamepad, such as ’Gamepad1’ is connected to the client’s device.
To retrieve a list of all connected gamepads, use UserInputService/GetConnectedGamepads
.
As UserInputService
is client-side only, this function can only be used in a LocalScript
.
Check out this article to learn more about adding support for gamepad input into your game and this page for articles on cross-platform development.
See also
UserInputService/GamepadConnected
UserInputService/GamepadDisconnected
UserInputService/GetConnectedGamepads
UserInputService/GetNavigationGamepads
UserInputService/SetNavigationGamepad
UserInputService/IsNavigationGamepad
UserInputService/IsGamepadButtonDown
UserInputService/GetSupportedGamepadKeyCodes
UserInputService/GetGamepadState
UserInputService/GamepadSupports
UserInputService/GamepadEnabled
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The |
Returns
Return Type | Summary |
---|---|
Whether a gamepad associated with |
Code Samples
Check Whether a Gamepad is Connected
This example returns whether Enum/UserInputType|Gamepad1
is connected to the client. It will print true if Gamepad1 is connected and false if Gamepad1 is not connected.
local UserInputService = game:GetService("UserInputService") local isConnected = UserInputService:GetGamepadConnected(Enum.UserInputType.Gamepad1) if isConnected then print("Gamepad1 is connected to the client") else print("Gamepad1 is not connected to the client") end