Can I detect if the player has a small screen?

I need to know if players are on a phone since Roblox only shows 3 tools in your backpack when on a small screen. This way I can let the players know that any other items are in their backpack.

I don’t want to use TouchEnabled since that could alert players on tablets, who (I believe?) can see all 10 items.

1 Like

There’s the check you want. Just show the “small mobile layout” when the last input mode was touch and the screen is too small to show all items. Use the studio emulator to find a good threshold. Don’t try to write a check “if phone then” based on input capabilities, because this doesn’t scale to all possible form factors. Stick as close to the requirements as possible, don’t abstract it into a device check.

1 Like

I meant to word my title like that, oops.

Is there any good way to check if something is small enough for me to worry about that though? I guess I could use absolute size or something.

There are multiple ways to get viewport size, I personally prefer workspace.CurrentCamera.ViewportSize because it’s short and doesn’t require additional objects (i.e. gui objects to check absolutesize).

6 Likes

Do you have any idea what this size is when Roblox decides to only display 3 items in a player’s backpack?

No, but the inventory code is open sourced here, so you could take a look:

2 Likes

Also recommend using Mouse.Move and if the viewport changed, check it on mouse move and you will be able to adapt GUIs, etc to the new screen size, if the player is playing on half a screen for whatever reason. Unless there’s a better way than Mouse.Move

2 Likes

I have been abusing UI constraints when it comes to different screen sizes. I really like being able to make it once and have it scale with everything.

workspace.CurrentCamera:GetPropertyChangedSignal("ViewportSize")

2 Likes