PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetGamepadState

The GetGamepadState function returns an array of InputObject|InputObjects for each input on the gamepad with each input’s last input state. You can iterate through the returned array to determine the last state of each valid input type for the gamepad.

To determine which Enum/UserInputType Gamepads are connected, you can use the UserInputService/GetConnectedGamepads function.

Since it only fires locally, it can only be used in a LocalScript.

Parameters

Name Type Default Description

A Enum/UserInputType value corresponding to the gamepad you want to get the state of.

Returns

Return Type Summary

Array of InputObjects.


Code Samples


UserInputService:GetGamepadState

This example returns and iterates through an array of the last input types for the GamePad1 Enum/UserInputType. The example’s for loop prints the InputObject/UserInputState of each returned input InputObject.