How can you get right gamepad icon?

There’s no real info here UserInputService | Documentation - Roblox Creator Hub to tell you what specific icon to show. Like how do I know if they’re on Xbox or PlayStation

Do you want to know the platform or do you want the right image that corresponds to the platform? The two methods for input mappings are designed to relieve developers of bothering with keeping track of the console type.

They receive a KeyCode and give an image you can use instantly (GetImageForKeyCode) or a string (GetStringForKeyCode) that you can map to your own custom icons.

1 Like

The second option, I think

You can use UserInputService:GetImageForKeyCode to determine what type of gamepad device a user is using.

local UserInputService = game:GetService("UserInputService")

if UserInputService.GamepadEnabled then
	local Image = UserInputService:GetImageForKeyCode(Enum.KeyCode.ButtonA)
	if Image == "rbxasset://textures/ui/Controls/DefaultController/ButtonA@2x.png" then
		print("Default controller.")
	elseif Image == "rbxasset://textures/ui/Controls/XboxController/ButtonA@2x.png" then
		print("Xbox controller.")
	elseif Image == "rbxasset://textures/ui/Controls/PlayStationController/ButtonCross@2x.png" then
		print("Playstation controller.")
	end
end
3 Likes