How to check if user has mobile controls?

I’m trying to prevent this:

On phones I’d like to move this button up a bit and make it smaller. On PC, I want to leave it where it is.

I’ve searching around a bit and I can’t find the definitive way to check if my player is running on a phone or not. There’s a bunch of hacks from 2016. How do I do it today?


Most solutions will probably be to check UserInputService.TouchEnabled and also ensure that there’s no mouse. That pretty much guarantees the existence of the jump button, and therefore lets you reposition accordingly.


TouchEnabled might be the way to go in this, and perhaps think about checking if there is no mouse button being clicked, by a “if not” statement?

1 Like

You might also want to make sure GamepadEnabled is false so that controller users don’t get registered as having touch screens.

Edit: For clarity, I mean using a console controller with a touch-screen laptop.


This was a good explanation of the best way to handle this from a post a few years ago; you should still handle it the same way today.

Yeah I found that thread and found it unsatisfactory.

I just want to fix my UI for phones. I don’t want to get drawn into an ideological fight about whether I should write platform specific code or not.

Writing a GUI that looks good at all resolutions is too hard. I want to do two - Small and Large. Websites do this all the time. It’s normal.


He’s not saying you shouldn’t have device specific UI, he’s saying you should change it dynamically based on the last input rather than trying to figure out the device they’re on.

This makes sure that it will function on all devices properly as there’s no surefire way to check the specific device type.

Use this to check if the player has touch controls.
Sorry for bumping.

local touchGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("TouchGui")

if touchGui then
--has touch controls
--doesn't have touch controls
1 Like