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.
PC UI EXAMPLE:
MOBILE UI EXAMPLE:
Does anyone have any tips on how World Zero achieves this?
February 7, 2022, 4:47pm
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.
February 7, 2022, 4:52pm
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”
February 7, 2022, 11:23pm
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
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:
Don’t try to detect “platform” and then make your game change based on that.
You should be looking at last used input mode and screen size of the device, and use changed events on the input mode and screen size to react dynamically to the user’s device. You cannot dumb down all possible device configurations and user preferences to a single platform value.