Is it possible to detect the devices type that a user is on in-game?

Hey everyone. Happy Thursday.

I’m currently working on a new project called Tunnels and want to make the game available on all devices; however, I understand that different device types have different power outputs. For example, the FPS and screen size are completely different switching from my iPad to my phone. How can I detect which type of device a user is using in-game so that I can give them the best performance possible? I’m aware that it’s possible on the devforum and on the website but don’t know how to reach that in game.

Here is it detecting which device I was using on the devforum:


Here is Roblox detecting your device from the website:
https://www.roblox.com/reference/deviceinfo

1 Like

There is no absolute way to detect device type, however numerous functions and properties exist which you can utilise, such as IsTenFootInterface for consoles or TouchEnabled for mobile devices.

Mobile example

if game:GetService("UserInputService").TouchEnabled then
    print("Player is using a touch-screen device")

    -- could additionally check for mobile gui in playergui
end

I recommend designing your game in a way which supports all device types without creating edge cases for mobile, console or pc.

@Tiffblocks addresses why detecting the specific device type isn’t practical.

3 Likes

I understand what you mean; however, I’m more concerned about determining which type of mobile user the player is (Windows, Apple, Android, etc.) so that I can set the game’s graphical and performance requirements to better accommodate their experiences. After reading Tiff’s post, I understand why I can’t assume anything; however, Im tying to determine the power of the device for performance to allow better devices to experience better graphics and low performance devices to experience better FPS

Is it impossible?

2 Likes

From what I am aware, yes it is impossible, mainly because the feature would be “abused” to create specific edge cases within your games.

As for ways to optimise your game to support each device type and platform, I’m not able to provide that much assistance there so you might want to look into creating a new thread asking for advice.

1 Like

If your goal is solely to provide different graphics for better performance on low-powered devices, then you can do some framerate detection to see what they can handle.


Start with the middle graphics level (we’ll call this 5). If the framerate is at or above 60, raise it to the next level (6). Otherwise, lower it a level (4).

When going up, if you drop below 60, go down one and save that as the highest detail level. You may want to try again in 5 or 10 minutes just in case the FPS dropped for some other reason.

Constantly watch the FPS. If it dips down for a long time, lower the detail one and save that as the new highest level.


I have never implemented a system like this but this sort of thing should work. I’m pretty sure Roblox’s automatic quality level does something similar. You don’t need device info to find out how powerful it is. Sometimes it can be misleading anyway:

This laptop is powerful enough to run VR and have tons of stuff open at once. You would be wrong to assume it needs a low quality level just because it’s a laptop. You would also be wrong to assume it can handle a high quality level solely based on computer specs – if it switches to battery power then it can handle much less than before.

Performance is very situational and taking every factor into account correctly is near impossible and it’s very privacy-invasive. You’re not going to be able to predict a good detail level without looking at what programs are running on my computer, what specs it has, and if it’s on battery power. I don’t really want every Roblox game snooping on my whole computer. You’ll have better accuracy by looking at FPS at different detail levels anyway.

10 Likes