I made a ModuleScript (not really usefull) that detect almost as same as UserInputService:GetPlatform(). It can tell the different between phone and tablet, Although, all the feature is using UserInputService.MouseEnabled or UserInputService:TouchEnable i guess.
To use:
--// Install to your LocalScript
local PlatformDetector = require(game.ReplicatedStorage.PlatformDetector)
--// Check the platform
print(PlatformDetector:Check())
--// Add logic
if PlatformDetector:Check() == "Phone" then
--// Your code
elseif PlatformDetector:Check() == "Tablet" then
--// Your code
elseif PlatformDetector:Check() == "PC" then
--// Your code
elseif PlatformDetector:Check() == "Console" then
--// Your code
end
This is a pretty good resource although for some feedback, One you mentioned in your post about a function called UserInputService:GetPlatform. It would be amazing if that function actually did exist but it currently does not.
Now onto the module. First off I want to make it clear that it is a good resource although there are some changes I would make to it. The first being with the console detection. As you know roblox is currently supported on both Xbox and Playstation platforms. Now by just using GamepadEnabled the logic in your game will have no way to tell between the two platforms. This creates a massive problem when it comes to having custom keybindings on screen for the different controllers. A way you can get around this is by using :GetImageForKeyCode(). I like to use Enum.KeyCode.ButtonA for this because it returns either ButtonA for Xbox or ButtonCross for Playstation, Thus allowing you to tell between the two platforms.
Next, is the clash between PC and Console. Now here’s where the biggest issue arises, You can connect a controller to PC and connect a Keyboard to a console. Now you can also do both of these things when it comes to mobile but due to your way of detecting the screen viewport size I highly doubt this issue will be persistent on mobile. PC and Console on the other hand is the biggest issue. From my experience developing games on both platforms I have realized that roblox tends to overlap a lot of UserInputService bool values. An example would be if you had a controller connected to a PC. If you called :KeyboardEnabled() it would obviously return true but if you also have a controller connected :GamepadEnabled() will also return true and most likely :GamepadEnabled() will overlap over :KeyboardEnabled() and in turn assume the player is on a console when they are not. The same goes for Console having a keyboard connected. Sadly I do not believe there is a way to combat this issue unless roblox does eventually release an official :GetPlatform() to UserInputService.
Everything aside, This is a great resource! Keep up the good work!
Ah I see, I did not know that this was an actual function under the InputService class. Still does suck that we do not have access to this as it would make our lives a lot more easier than having to do platform detection manually with all these work arounds.