How can I determine the user operating system and device?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to determine the user platform. I want to know if the user is on a ipad or a phone or a pc or a android device to avoid having scaling issue with my gui.
  2. What is the issue? Include screenshots / videos if possible!
    I can’t actually differentiate if the user is on a ipad or a phone.
  3. What solutions have you tried so far?
    I made this script however it can’t differeciate ipad user from the phone user. I also tough that I could use the screen resolution however it wouldnt work as there’s many different screen size and I want my code to be future proof.
local getUserOS = function()
	if userInputService.TouchEnabled and not userInputService.KeyboardEnabled then
		return "mobile device"
	elseif userInputService.TouchEnabled and userInputService.KeyboardEnabled or userInputService.KeyboardEnabled then
		return "pc"		
	end 
end

How are you scaling your Gui?

I don’t think so anyway
Only core scripts can access the Platform the user is on.

This thread is from 2016 but AFAIK nothing has changed about UserInputService. The consensus is still that you don’t need the device platform. You should be adjusting your interface based on screen size and input type.

I am using different gui.

I think that a way I can do this is by identify the user screen resolution and UserInputType.

Currently, there is no known way to determine devices so specifically. You could always use the technique you demonstrated in the OP, which is as good as it will get without any new updates from Roblox.

Even if this would be possible, what’s the actual use of being able to detect devices so precisely? You earlier said that you’d be using different UI’s for different devices - why would you need to do something like that?

There is a guaranteed method of detecting if a user is on console by using GuiService:IsTenFootInterface() that can only be used on a local script but for other device’s you need weird ways to detect what device they are on which have no guarantee that it is detecting the correct device. A reason for using a method to get what device somebody is on is to increase/decrease the quality of the game to give the user a better experience or for console in specific to enable/disable features according to Roblox’s rules on games that support console.