I have a module that checks on the platform the player is currently using. But, under mysterious circumstances, the module detects mobile as PC, which disabling all mobile functions
local UserInputService = game:GetService("UserInputService")
--[[return function()
if UserInputService.GamepadEnabled then
return "Console"
else
if UserInputService.TouchEnabled then
if UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then
return "Desktop"
else
return "Mobile"
end
else
return "Desktop"
end
end
end]]
return function()
if UserInputService.GamepadEnabled then
return "Console"
elseif UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled then
return "Mobile"
else
return "Desktop"
end
end
(from my game Muffin Assault. Pay attention to “platform” on top left)
From my discord server, some people believed that Roblox chat was the cause of this. Still, I’m not certain about this. So are there any other causes that made this happen?
That sounds somewhat likely. Your code might be detecting that the keyboard is the one enabled due to the user being in chat.
Perhaps try checking if the user is in chat and making sure they aren’t before you return the result?
Actually, sort of a hacky solution, but you could perhaps try disabling chat when the player first joins, and only enabling it again when you finish checking for the device.
(Might not work if the glitch would also happen if you use the mobile keyboard outside of the game)
Also, assuming this bug doesn’t happen with ContextActionService, you could also perhaps try creating a button like that, and checking wether or not it exists/is visible to determine if the device is mobile or not. (And then get rid of the button so it doesn’t block anything)
ContextActionService would do so, but I have already found a workaround to resolve this issue. By simply adding _G variable for the initial platform. And of course, it seems to work well, and no recent platform bug reports are made