Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. local function DetectPlatform()
  2.     -- TenFootInterface was made exclusively for XBOX One, so easy to eliminate this one
  3.     if game.GuiService:IsTenFootInterface() then return "Console" end
  4.    
  5.     local function inferMobileType()
  6.         if workspace.CurrentCamera.ViewportSize.Y > 600 then
  7.             return "Tablet"
  8.         else
  9.             return "Phone"
  10.         end
  11.     end
  12.  
  13.     local uis = game:GetService("UserInputService")
  14.     -- Assuming that PC's would not have these kinds of features, so figure out which type of Mobile it is
  15.     if uis.AccelerometerEnabled or uis.GyroscopeEnabled then return inferMobileType() end
  16.     -- So still remaining are PC's and Mobile devices without the above features, We'll use the presence of a keyboard/mouse to distinguish the two
  17.     if uis.KeyboardEnabled or uis.MouseEnabled then return "PC" end
  18.     -- Finally we assume the device has to be mobile
  19.     return inferMobileType()
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement