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

Is there any way to test what device a player is on?

Asked by 7 years ago

Is there any way to test what device a player is on? (like: Console, PC and mobile) (but mainly test for mobile)

Im creating a game and you need to buy things in a shop. You also have currency. I display the currency on GUI's.

When i check the roblox device emulator to see if the GUI's positions are good i see that on mobile the currency 'meeters' are at wrong positions.

So i need a way to check for mobile so the scripts can position the GUI's correctly for mobile (but not for PC or console) Is there any way to achieve this effect?

1 answer

Log in to vote
1
Answered by
Tomstah 401 Moderation Voter
7 years ago

Simply access UIS (UserInputService) and see if Touch is enabled. This is typically the best way to tell.

IsMobile = game:GetService("UserInputService").TouchEnabled

if IsMobile then
    --Etc.
end
0
I’m not the person who asked this but can you explain what UIS is a little bit more? I’m always hearing it but can’t figure out what it does/is cmgtotalyawesome 1418 — 7y
0
Oh sure! UIS is a service, so very similar to most things you've probably used like RunService or ServerScriptService, or more! However, the UIS specializes in, as you may have guessed, User Input. It handles information that has to deal typically with what the client is sending via a keyboard, mouse, touchscreen, etc. Here's the article: http://wiki.roblox.com/index.php?title=Userinputservice Tomstah 401 — 7y
0
Is this filtering enabled compatible? User#17353 0 — 7y
0
Well it only works on a local script because why would the server ever be touch screen. So if you're working with guis you shouldn't have to mess with events all to much, just write it into the gui's code! Tomstah 401 — 7y
0
Thanks!! User#17353 0 — 7y
Ad

Answer this question