How to check if user is on tablet

Hey everyone! I’m trying to make my game compatible with more devices, however I cant figure out how to make it on tablet. I got it right on Computer and phone, but not on laptop.

I think I need an new one for Phone too, as it is returning that I’m using an phone instead of Laptop.

I tried to search the forum, but I could’nt find anything

You can only say if person is on touch device, not if its 100% mobile/tablet.

local UIS = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")

if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled
   and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then

   -- mobile device

end

Also here is what I googled: “check if plr is on touchdevice roblox”grafik
grafik
First link

1 Like

No. I want to know if a user is on a tablet, not on a phone.

You can’t as I said
“You can only say if person is on touch device, not if its 100% mobile/tablet.”

You can say Tablet = Keyboard and TouchDevice…

I hope this helps.

Try:

local UserInputService = game:GetService("UserInputService")

UserInputService:GetDeviceType = Enum.Tablet

I hope this helps and I didn’t make any mistakes.
Source: DeviceType | Roblox Creator Documentation

1 Like

Hey! UserInputService:GetDeviceType can only be accesed by CoreScripts( Because it is RobloxScriptSecurity) so I cant use that

Oh! Sorry I was trying to find a quick answer. I thought the dev hub would help.

basically as I said
“Not possible”.

1 Like

Not only is that locked behind RobloxScriptSecurity, there are about five different mistakes in that script.

Tablet is the member of the DeviceType Enum, not its own Enum. You’d have to specify Enum.DeviceType.Tablet, or check if what GetDeviceType returns has a Name of “Tablet”.

Methods can be referenced with . and called with either . or :. You can’t reference a method with : without calling it. Specifically, x:y() is shorthand for x.y(x), so it wouldn’t make sense to store that the first parameter when called is going to be x, meaning you can’t store x:y on its own.

Here you’re assigning a value to GetDeviceType, which probably isn’t what you meant to do. If you’re checking equality, it’d be ==, but you can’t just replace that = with a == and call it a day. You need an if statement or somewhere to store the boolean.

4 Likes