Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do i make separate Gui for mobile and pc?

I’m making my game both for mobile and pc but I can’t seem to figure out how to change Gui base on their device. Example:

local compGui = game.StarterGui.ScreenGui.Frame1
local mobGui = game.StarterGui.ScreenGui.Frame2

(this is a test script)

now in the test script I want it that when on pc Frame1 is visible while Frame2 isn’t. Then on mobile it will be Frame2 that’s visible and Frame1 isn’t. Also should it be in a local script or not? Thanks!!!

2 answers

You use UserInputService to find this out.

There is a property called TouchEnabled that is for mobile devices and if its not touch enabled, you can assume its a xbox or PC user. Use this with an if statement for your usage purpose.

Yes, it should be in a local script.

Wiki link here: https://developer.roblox.com/en-us/api-reference/property/UserInputService/TouchEnabled

In addition there is MouseEnabled, KeyboardEnabled, and GamepadEnabled.

It is easy! No scripting involved. By default, a Gui's size properties use Offset and not Scale. Simply on every GUI instance, in properties, change offset to 0, then scale normally and it should work.

This discussion is preserved as it was. New answers, comments, and votes are closed.