There's no native way to get the user's device type. However, there are some functions that may interest you:
UserInputService.AccelerometerEnabled
UserInputService.GamepadEnabled
UserInputService.GyroscopeEnabled
UserInputService.KeyboardEnabled
UserInputService.MouseEnabled
UserInputService.TouchEnabled
UserInputService.VREnabled
GuiService::IsTenFootInterface
Mobile devices have MouseEnabled and KeyboardEnabled false. Most mobile devices should have an accelerometer and gyroscope.
Console devices have KeyboardEnabled false, and IsTenFootInterface true.
I may have missed some functions or properties from the wiki, but you can explore yourself.
Also, here's a snippet of code I found on the DevForums, I forgot who the original author was, so I apologize if it was your's.
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
function getplatform()
if (GuiService:IsTenFootInterface()) then
return "Console"
elseif (UserInputService.TouchEnabled and not UserInputService.MouseEnabled) then
local DeviceSize = workspace.CurrentCamera.ViewportSize;
if ( DeviceSize.Y > 600 ) then
return "Mobile (tablet)"
else
return "Mobile (phone)"
end
else
return "Desktop"
end
end
1 comment
yeah