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

Detect if user is on mobile?

Asked by 6 years ago

What I wanted to do is enhance gameplay by adjusting the GUI for mobile users. For example, on PC or Tablet, you will have the full GUI, but on Phone, you have to press a button so you get the full GUI, otherwise, the only thing on your screen is the button for the full GUI. (For example, in MeepCity.) I don’t want to have that on PC and Tablet. Can someone show me an example on how to do this?

2 answers

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago

You can't check if the user is on mobile, but there are workarounds.

You don't need to check if the player is on a phone to realize that phone's have small screens. You can use the camera's ViewportSize property to identify the size of the screen you are working with, and when it's under a certain size, change the GUI to be the open/close menu GUI. This is better than checking if a device is a phone because you never know if someone likes to play with a really tiny window on PC, or someone has a extremely large device screen :p

Hope this helps! :)

Ad
Log in to vote
0
Answered by
uhTeddy 101
6 years ago

An easy way to do this is by using the code below in a localscript

local uis = game:GetService("UserInputService")
local ismobile = uis.TouchEnabled

if ismobile then
    -- code
end
0
No, this is true if a user has a touch screen PC. User#19524 175 — 6y
0
I have a touch screen laptop lol. this wouldn’t work 100% of the time 1000knives 9 — 6y
0
Unfortunately (whether touchscreen computers activate it or not), TouchEnabled still won't differentiate between mobile and tablet. saenae 318 — 6y
0
@1000 yes, 100% of the time. It means it still works sometimes. User#19524 175 — 6y

Answer this question