I’m trying to work on UI that will work for both console and PC and I’m trying to avoid using
UserInputService.GamepadEnabled
as some people leave their gamepad plugged in.
local UserInputService = game:GetService('UserInputService')
local InputType = UserInputService:GetLastInputType()
local function inputChanged(inputType)
InputType = InputType
end
for _, v in pairs(Gold.Mid:GetChildren()) do
if v:IsA('ImageButton') then
if InputType == Enum.UserInputType.Gamepad1 then
print('Controller')
else
print('Computer')
end
v.Activated:Connect(function()
print('Button pressed')
end)
end
end
UserInputService.LastInputTypeChanged:Connect(inputChanged)
What I want is the prints inside the for loop to print either controller or computer whenever the input type has changed. Reason for this is when the controllers plugged in I want to set the selected button, and when it’s not plugged to unselect