UI mobile issue


Im having a recent issue regarding UI for mobile support.

I want to make a script that, basically, if your on a mobile device, it changes the position of a UI.

I dont know where to start with this, as im bad at UI scripting regarding this.

I have used AutoScale Lite Plugin and that does not seem to help much.

any help is appreciated.

Hey, are you doing this because potentially the UI isn’t in the right place on different devices? I think an easier method would be for you to use UIAspectRatioConstraints. You can do this automatically with AutoScale Lite actually, which is the plugin you’re using. Select the UI element in question, convert both size and position to scale rather than offset, and then add a UIAspectRatioConstraint.

Anyways, answering your question. You can use UserInputService to check for properties a mobile device might have if you really wanted, although I’m not sure if this will be accurate 100% of the time. Try to following:

local UserIS = game:GetService("UserInputService") 
if UserIS.TouchEnabled and not UserIS.KeyboardEnabled then
   -- user is probably on a mobile device
    print("mobile player")

You can replace my print statement with changing the position, but I’d urge you to try and make it work with AutoScale Lite using the steps I gave you if you’re simply doing this because the UI is offset on different devices.

1 Like


thanks, ill test this out.

i kept trying, yet it messes up still on mobile with auto lite.

You need to size/position GuiObjects according to scale so that they scale according to the native device’s screen resolution.

1 Like