I’m trying to check the player’s platform (mobile, console, or PC) to make buttons visible for mobile only, but I’ve run into a problem in which it shows the player is on mobile when tested on studio, but when tested on a real phone, it doesn’t work and prints “Computer” instead of “Mobile”. Please help me, provide another proficient and best way/method to obtain the player’s platform, if applicable/possible.
Here is my script:
function PlatformService.Client:GetPlatform(player)
if not player then warn("No player provided!") return end
local GuiService = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")
local IsMobile = UserInputService.TouchEnabled
local IsConsole = UserInputService.GamepadEnabled
local IsComputer = UserInputService.KeyboardEnabled
if IsMobile then
print("Mobile!")
return "Mobile"
elseif IsConsole then
print("Console")
return "Console"
elseif IsComputer then
print("Computer")
return "Computer"
end
end
Thanks for your time.
Note: I’m using the Knit framework but that won’t affect it anyways because the scripts works just fine overall, and I’ve tested it on studio tho.