How to detect if Player is using a Phone or Tablet?

I know there have been multiple threads solving this issue, but I was unable to find a concrete answer. The closest answer I have gotten was regarded from this thread: How to detect if Player is using a Phone? - #4 by buildthomas

However, within the solution, the poster said not to use this method because it is very easy to misclassify devices which is why I’m looking for any alternatives.

The reason why I’m looking for this is that I want different UI to instance depending on the player’s platform. For example, World Zero has a custom UI for mobile users, when compared to PC users.



Does anyone have any tips on how World Zero achieves this?

Could I ask why would you need this? Are you positioning the guis differently on different platforms?

Yep I want to do something similar to World Zero, where mobile players have a different set of UI

You could check the KeyboardEnabled property in the UserInputService.

Local script inside the StarterPlayerScripts or StarterGui

local uis = game:GetService("UserInputService")

if uis.TouchEnabled then
elseif uis.KeyboardEnabled then

I wouldn’t recommend using TouchEnabled because that still returns true on laptops with a touchscreen.

False. When I tested it on my touchscreen laptop it still says “PC”

For mobile UI I tend to use a mix of UserInputService.InputChanged (I check for the Touch UserInputType) and then a mix of the screens resolution in pixels. You can get resolution with Camera.ViewportSize.

It must depend on the specific model of laptop then because it returns true on my laptop. Either way it would still be a better practice to check for a keyboard because you can’t have a keyboard on a phone but you can have a touchscreen on a computer.

It does, though I’m not sure why it doesn’t on yours.

I’d recommend reading this reply by buildthomas:

1 Like