Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there an efficient way on how to detect if someone is on a mobile device?

Hi, I'm making a game using UserInputService, and I need a way to detect if someone is on a mobile device. I know there are some scripts that use UIS.TouchEnabled, but what if they have a keyboard connected to their mobile device?

Thanks in advance!

1 answer

✓ Accepted answer

Yes, you can detect all devices with UserInputService. Here is an example:

UserInputService.GamepadEnabled -- Xbox. If they plug in a Mouse and Keyboard, it will switch to KeyboardEnabled.

UserInputService.KeyboardEnabled -- PC. If they plug in a Xbox Controller, it will switch to GamepadEnabled.
	
UserInputService.TouchEnabled -- Mobile. If they plug in a Xbox Controller, it will switch to GamepadEnabled. Same with Keyboard, it will switch to KeyboardEnabled.

1 comment

0

Thanks so much! Really helpful! Will it work on a while loop?

This discussion is preserved as it was. New answers, comments, and votes are closed.