How to detect if Player is specifically using a Phone or Tablet?

  1. What do you want to achieve?
    I want to be able to detect whether a player is using a phone or a tablet. This is not the same as checking to see if the player is on mobile.

  2. What is the issue?
    I am unsure how I can approach this problem

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I was thinking about checking the player’s screen size to see if the screen is big or small. The problem is this may be inconsistent if some kind of large cellular device is considered a tablet rather than a phone (not sure if that might be a problem). There was a similar post regarding the question, but it doesn’t answer how to detect the difference between a phone vs tablet.

I am trying to hide one or the other depending on what size of the player’s screen is:
image

3 Likes

It’s not possible to detect if it’s specifically a Phone or Tablet. I would recommend just setting the Size and Positions to scale so that it automatically scales correctly for all devices.

Even if you could see if it’s a tablet or phone, some tablets are larger and smaller than others, and the same goes for phones.

3 Likes

You could try Murder Mystery 2’s approach, which is to ask the player which type of device they’re using (phone/tablet)

4 Likes

The best possible solution for this might be to check the ViewSize properties from your LocalPlayer’s :GetMouse() method (And yes; we are using GetMouse in spite of having touch devices, as while the genuine mouse related methods may not work, the resolution is still there).

We can then use these properties to consider the device a tablet after a specific width and height or a mobile otherwise.
The smallest common tablet resolution is around 768x1024 pixels, while on average mobiles should be around 350x800 pixels.

Here’s an example function that checks the mouse viewsizes compared to the previously mentioned tablet size to determine the device type:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local MinimumTabletSize = Vector2.new(768,1024) --Set this to what you think is a good minimum tablet resolution
function CheckTouchDeviceType()
      if Mouse.ViewSizeX>=MinimumTabletSize.X and Mouse.ViewSizeY>=MinimumTabletSize.Y then
            return "Tablet"
      end
      return "Mobile"
end

Sorry for posting it this late, but hopefully this may be a solution to a problem like this with checking specific device types.

4 Likes

ScreenGui.AbsoluteSize gives you the pixel resolution of current display viewport (Monitor basically). You can make specific cases around that. A more general approach would be scaling the uI with UI Scale but then the UI just looks distorted.

1 Like

You can use AutoScale lite to scale them to fit on each device perfectly!

Have a great day!

Love,
Callan.

1 Like

Problem with this is that the scale changes drastically between tablet and phone. It could work, but I try to modify it in a way that acts like Roblox’s CoreGui.

I was thinking this might be the only solution, but if there another better solution that checks if it’s tablet or mobile, the solution may swap :+1:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.