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

Is there a way to detect the device the player is using?

I want to have a GUI run mobile ads to award players points but there's no point in having a PC player's screen's being taken up by an essentially useless GUI. Any way to detect if the local player is using a touchscreen tablet/phone?

1 comment

0

http://wiki.roblox.com/index.php?title=API:Class/UserInputService there is a way to detect if a user is on mobile or not.

1 answer

You can use the UserInputService, here's an example.

Here's how to detect if its mobile

(LocalScript)

--Made by ElmEditor
--To answer question on scriptinghelpers.org
game:GetService("UserInputService").KeyboardEnabled==false and game:GetService("UserInputService").TouchEnabled==true then --If there is no keyboard but a touch device
print 'Mobile'
elseif
game:GetService("UserInputService").KeyboardEnabled==true and game:GetService("UserInputService").TouchEnabled==false then --No touch device but a keyboard
print 'Computer/Laptop'
else --If its not Computer/Laptop or Mobile
print 'Xbox or other' --It'd be Xbox
end
--Must be localscript

Note: If somebody is playing on a gamepad and keyboard is enabled it'd print "Computer/Laptop", but if they are playing on Gamepad w/ Touch Device it'd print Mobile. You can add other detections if you'd like.

Hope this helps, if it did press that ^ button; it helps alot!

-ElmEditor

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