Detecting if the user is on phone or ipad

I want to make a GUI that if the player is in phone it will show the phone gui and if the player is on ipad/tablet the ipad/tablet gui will show.

1 Like

Insert a LocalScript in StarterGui and type this code:

local UIS = game:GetService(“UserInputService”)

if UIS.KeyboardEnabled and UIS.MouseEnabled and not UIS.TouchEnabled then
print(“Pc”)
elseif not UIS.KeyboardEnabled and not UIS.MouseEnabled and UIS.TouchEnabled then
print(“Mobile/IPad”)
end

1 Like

The easiest way to check if a player is using a phone is:

local userInputService = game:GetService("UserInputService")
local isTouchEnabled = userInputService.TouchEnabled -- Returns true or false.
if isTouchEnabled then -- You'll also need to check if keyboard and gamepad aren't connected.
   -- Parent the GUI, make it visible, etc.
end

But checking if a player is on mobile isn’t really needed as you should be making your GUIs fit to scale on any type of device and any screen size, too. That way, you won’t need to re-write the whole client-sided GUI code three times, you’d just have it written out once. Don’t forget that if you do choose userInputService.TouchEnabled, you’ll need to put that into a local script so it runs on the client.

local UIs= game:GetService("UserInputService")

if userInputService.GamepadEnabled == false and UserInputService.KeyboardEnabled == false and userInputService.TouchEnabled then
	--do stuff
end