How to detect when someone plugs a controller in?

Hello, I’m trying to add controller/Xbox support for my game.

I know that you can use GuiService:IsTenFootInterface() to detect whether someone is on console, but how do you detect when someone plugs in a controller to their PC? I know this is possible, because games like Jailbreak and Driving Simulator have achieved this somehow.

Any help please?

Isn’t this what UserInputService.GamepadConnected can be used for?


Thank you

this post has to be enough chars