Issue with checking player devices

I wanted to make a script to get the players device. I wanted to check if they are on Tablet, Phone, Desktop, etc.

But I have found an issue with the way I am checking the players device (Checking if inputs are connected)

I remembered this player property called “DeviceType”, but I searched it on the DevHub and got no results.

Here is my code.

if game:GetService("UserInputService").KeyboardEnabled == true then
	print("Player is on a Computer.")
else
	print("Player is on a Mobile Device.")
end
1 Like

The way your checking if a client is on a mobile device works perfectly fine. What’s the issue?

2 Likes

Maybe UserInputService.TouchEnabled will help

local UserInputService = game:GetService("UserInputService")

if UserInputService.TouchEnabled then
	print("Player is on a Mobile Device.")
else
	print("Player is on a Computer or Xbox.")
end

Player.DeviceType only inside the corescript so you cant access to it

1 Like

I know it works fine for checking if the player is on a mobile device, but I want to check if the player is using a phone or tablet.

I want to check the players actual device like Phone, Tablet, Laptop, etc.

Why would you do that though? Your game should be able to adapt to diverse input types. If I am playing on a laptop I should be able to connect a controller and play with the controller. Likewise, if I have something like a Microsoft Surface laptop (or any other with touchscreen), I should be able to touch the screen and have the game adapt to the diversity of the input types. Some tablets are also literally becoming laptops, so for players that might like playing on one with their keyboard hooked up should be able to use keyboard controls.

UserInputService.LastInputTypeChanged and UserInputService:GetLastInputType should suffice, but you can read more UserInputService documentation as there are more events and methods documented that may help you.

1 Like

I was doing this for a custom leaderboard that shows the player’s devices, and yes, I will look into UIS more to find a way to do this.

I don’t see a use for this, just say they are on mobile. Why would any player need to know if another player is on phone or tablet? You could look into screen dimensions but that can be inaccurate.

If your issue is scaling than like @sjr04 stated your games UI should be able to adapt to it.

1 Like