So I’m making a survival game, and I need to find out a most reliable way to get what device a player is on. I use MouseEnabled, but I need to know if the players are on a phone or tablet to size a frame’s template I have, or is there a way to make text without textscaled size to 14 if a player’s on a phone, otherwise 20?
Your best bet is probably going to be something along the lines of:
Why go through the trouble of checking whether or not the player’s on a phone? Why not just check their screen size directly and resize your text based on that?
Wouldn’t I have to directly add the frame sizes for each device then?
Nope. If you think the screen size is too small, then set the text scale to 14. Otherwise, set the text size to 20. How to decide whether the screen size is too small is up to you.
This is good advice because even desktop players can have small resolutions. If you set their text size to something large just because they’re on desktop, then you’re going to inconvenience them.
Hm, is the VGA a most common desktop resolution? I dunno.
It isn’t, but players can be playing in windowed. There are also large tablets like the 12.9 inch ipad pro which have screens larger than most laptops/netbooks. Your text would appear very tiny on those devices if you resized your text solely by device type.
I’ll just used TextScaled and hope it works. Ty though
Using relative scale for sizing UI components is usually preferable. You ultimately don’t know how large the text is going to be on the client, because even the pixel dimensions (e.g. Camera.ViewportSize or AbsoluteSize of full-screen ScreenGui) don’t tell you about the resolution of the screen or physical size, so you don’t really know how large (in inches or cm) 14pt text really is. I size the fields as big as I can, and use TextScaled, and I use the emulator in Studio to spot check new layouts on a few different devices.
You may benefit from considering that “VGA” is not a resolution. Also, regardless of the video output format on a given device, pixel resolution varies widely from one machine to another, and can change whenever the output display changes.
Apologies for the bump but I’ve recently stumbled upon something that may help with issues like this
If you create a frame and set it’s size to {1,0},{1,0}
(stretch across entire screen), then you can use the AbsoluteSize
property to determine the size of the screen.
Using this property you should be able to do some calculations to determine what the size/position/etc should be.
There’s probably a more efficient method of determining this but I can’t find any on developer.roblox.com
While I know this isn’t ideal, it’s the best I can find and I’ve been trying to solve an issue like this for ages without needing to use scale. Hope this helps!
Alternatively, you could use the Camera’s viewport resolution instead. I can’t add much, but that’s all I can say about it.
local Player = game:GetService('Players').LocalPlayer
if player.PlayerGui:FindFirstChild('TouchGui') then
print('User is on a phone or tablet')
else
print('User is not on a phone or tablet')
end