Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make different GUIs for different devices?

Asked by 7 years ago

I am making a GUI but it works better with a mouse than a touch screen device. How do I make a separate GUI for other devices? It might be confusing so an example of this is a game called "Miners Haven", when I play it on my tablet the GUI is different from the GUI when I play on my computer. I want to make a GUI that works better with mobile devices, and a separate one that works better with desktop users.

1 answer

Log in to vote
1
Answered by 7 years ago

To get what device a user is on, you can simply use UserInputService like so.

local UIS = game:GetService('UserInputService')
if UIS.MouseEnabled == true then --All computer users are forced to have a mouse.
    print('The user is on a computer!')
elseif UIS.TouchEnabled == true then --For mobile.
    print('The user is on mobile!')
elseif UIS.VREnabled == true then --For virtual reality (maybe roblox will be coming out on this soon, never seen roblox on VR before.)
    print('The user is using a virtual reality headset!')
else --Otherwise, the user is on XBOX.
    print('The user is on XBOX.')
end

and then you should script different GUIs for the different devices. More on UserInputService is here. Hope this helps!

0
Roblox has had VR for a while now. lukeb50 631 — 7y
Ad

Answer this question