What's the best way of detecting a player thats playing on Mobile or Xbox?

I want to know what’s the best WAY of detecting a player is on Xbox “or” Mobile. I read some forum posts but this was my answer, I could use some feedback for this.

(i am still not very good at cross platform scripting)

local UserInputService = game:GetService("UserInputService")
local lastInput = UserInputService:GetLastInputType()

if UserInputService.GamepadEnabled or UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled then 
	if (lastInput == Enum.UserInputType.Gamepad1) then
		-- do whatever balghehgesdhhrhkkoleeshb
	end
end

Why am I trying to get Mobile and Xbox?

You see I have a skill tree system that uses the “Move” function which is basically just hover mouse. And I doubt such things can exist on mobile or xbox so I wanted to do click on the icon and the info shows up and click it again and it goes away. I could use some help and feedback etcc

1 Like

for xbox you can use IsTenFootInterface. For mobile you can check if
https://developer.roblox.com/en-us/api-reference/property/UserInputService/MouseEnabled
https://developer.roblox.com/en-us/api-reference/property/UserInputService/KeyboardEnabled
https://developer.roblox.com/en-us/api-reference/property/UserInputService/GyroscopeEnabled

2 Likes

From what I heard and tested, 10 foot interface has some minor issues and isn’t 1 to 1

Only a small amout of games are made to react to the users imputs. e.g. player plugs in a controller and the game switches to a controller based gui. This also changes icons if applicable to show what actions a user can do within a gui.

This style of seemless switching is a lot of work but imo gives a far better feel to the game.

1 Like

Instead of detecting what device they are on you should check what there last input was because some PC users could use an Xbox remote for example. Some Xbox users could be using a small screen or use a mouse and key board. Sometimes players could change their input type whiles they are playing so one minute they could be using a mouse and keyboard and the next they could be using an Xbox remote.

Here is a great tutorial about changing players UI depending on what the players input is:

5 Likes

I have never been able to test on an xbox and it might have even changed in which case it might be a bug? I would also check the Roblox scripts as it includes the code for checking for the device type.

I mainly tested on a xbox controller, and I seen other “some” games have the same issue when it shows up when you aren’t even using a controller at all

I think I have also seen some games that do this. I feel this is more of a Roblox bug… not that I know the code they are using.

Either way I would still use it and if any issues occur report it as a bug.

Roblox does not natively support a way to check what device the player is using, only what kinds of input they’re passing. Just account for this in your code by making the movement system functional depending on what input is passed, rather than trying to change things based on the device.

1 Like