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

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

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

✓ Accepted answer

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

5 comments

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

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

0

Is this filtering enabled compatible?

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!

0

Thanks!!

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