Best method of detecting the player's platform (e.g. mobile, xbox, computer)

I’m trying to find the best and most efficient way of finding out what platform the player is on. I am aware that Roblox doesn’t give developers an easy read-only value that says their platform. Some people check through detecting a gamepad being plugged in, touch enabled, etc. But what if the player has a gamepad plugged into their computer? Or what if their laptop is touch screen? (these are all things I’ve tried but I’m afraid will not always be the best way.) So, what is the best way to accomplish this task?

TLDR: Detecting a gamepad or touch screen aren’t always reliable ways of checking the platform, so what is the best way of doing so?

Any replies are appreciated! Thanks!


What’s your use case for wanting to do this?

You should read later on in this thread before implementing this:

Typically, you shouldn’t need to know what the platform the user is on, unless you are trying to track some analytics related to platform. (pretty much the only use case where getting the platform is interesting)


Reading your reply, I might not need to do this after all. I wanted to create a UI that changes depending on the player’s platform. Lets say the player was on mobile, I want to have a cool dynamic comfortable coded gui that does all the same things as computer but is more space efficient (this would require different designs and code that’s why). Then on computer its a more expanded version of the gui. I thought it might be smart to detect the platform of the player then assign a specific version of the game’s ui to use for that platform. Would this be efficient, or better yet, even possible? If not, then how would I go about doing it? If yes, then how would I do that, as well? Thanks.


No, not by detecting platform. You’ll want to check the initial input mode and then change your UI whenever the input mode changes. The input mode is the variance here that you care about, not platform (because an input mode is not exclusive to platform, i.e. you can have laptops with touch screens, or phones/consoles with mouse + keyboard)

See these: (for setup) (for changes)


Thank you so much!


This is some code that’s quite popular around the community, may help you. It’s only an initialization though, you’d probably want to use a LastInputTypeChanged event.

function getPlatform()

    if (GS:IsTenFootInterface()) then
        return "Console"
    elseif (UIS.TouchEnabled and not UIS.MouseEnabled) then
        return "Mobile"
        return "Desktop"

There’s proper API available for getting the initial input mode, see above. No need to be hacky about it, and again no need to distinguish on platform unless you are doing it for some analytic purpose.


Actually, I could think of a few reasons you’d want to detect the platform the user is on. If a a developer wanted exclusive content for a specific platform, they’d obviously need to detect what platform the user is playing on.

For example, if someone wanted an exclusive camouflage for Xbox players only, you’d need to tell if they’re on Xbox or not to award them that said exclusive skin.


Sorry for bump, but I wanna add that another reason is to tell what Gui modifications to make to accommodate the mobile player, like a button to sprint for only mobile when a PC player can just use Shift.


You can already do that with UserInputService.KeyboardEnabled/UserInputService.TouchEnabled. If the keyboard isn’t enabled and touch is enabled, make a button. Otherwise, use shift.