How can I see when a Player changes from GamepadEnabled == true to GamepadEnabled == false?

How can I see when a Player changes from GamepadEnabled == true to GamepadEnabled == false?
(Player connects or disconects Xbox controller from pc)

1 Like

Try this:

--//Services
local UserInputService = game:GetService("UserInputService")

--//Variables
UserInputService:GetPropertyChangedSignal("GamepadEnabled"):Connect(function()
	if UserInputService.GamepadEnabled then
		print("Gamepad enabled")
	else
		print("Gamepad not enabled")
	end
end)

https://developer.roblox.com/en-us/api-reference/event/UserInputService/GamepadConnected
https://developer.roblox.com/en-us/api-reference/event/UserInputService/GamepadDisconnected
Use the built-ins, they pass the gamepad number to any connected callback functions.

Didn’t know those existed, thanks for showing.

New script:

--//Services
local UserInputService = game:GetService("UserInputService")

--//Variables
UserInputService.GamepadConnected:Connect(function()
	print("Gamepad connected")
end)

UserInputService.GamepadDisconnected:Connect(function()
	print("Gamepad disconnected")
end)