The Most Accurate Way To Detect The Player's Device

I want to know the most accurate way to detect what device a player is using, whether the player is on mobile, iPad/tablet, or PC?

Some people have said UserInputService:GetLastInputType().

Some people have used:

UserInputService.KeyboardEnabled and  UserInputService.MouseEnabled

To detect if someone is on PC

and this:

UserInputService.TouchEnabled and not UserInputService.MouseEnabled()

to detect if someone is on mobile.


Which method is the most accurate to detect which device a player is using?

(It doesnā€™t have to be a method listed above)

I would appreciate help to determine this, as I want to do my best to make the mobile experience for my game the best it could be.

3 Likes

This has been answered multiple times already. Please find your own answer before asking for one.

I donā€™t mean to be rude, but the OP asked for the most accurate way, not how to do this.

Some methods of detecting may be less accurate than others.


Also, what about Xbox? Would the best way be just to detect a controller input? I know the OP doesnā€™t mention this in their question, but Iā€™m intrigued.

3 Likes

Xbox can be detected using the IsTenFootInterface property:

if game:GetService('GuiService').IsTenFootInterface then
-- player is playing on xbox
end
2 Likes

Please read the post. Iā€™m asking for the most accurate. I know there are several ways.

2 Likes

Thereā€™s actually a method in the documentation, specifically GuiService:IsTenFootInterface that accurately detects if someone is on Xbox, which is why I didnā€™t include it in the original post.

Thank you for linking that reply. This is exactly what Iā€™m looking for. I can assume thatā€™s an accurate method given how many likes it got. I appreciate your help.

3 Likes

You should not detect whether the player is on a particular platform, you should check what their latest input mode is, and what their screen size is, and adjust the UI according to that.

This is written in the post you have linked (note the edits and such made to the post). Please do not use the outdated snippet in here as it will lead to broken UX on many kinds of devices and use the API I linked there instead.

5 Likes

Yep. I noticed the edit on your reply and took your advice.

Thanks for your help :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.