How to detect if Player is using a Phone?

Update: UserInputService has a cool feature UserInputService.TouchEnabled

local userInputService = game:GetService("UserInputService")

if userInputService.TouchEnabled then
	print("The user's device has a touchscreen!")
else
	print("The user's device does not have a touchscreen!")
end

which is good enough to detect touch enabled devices

1 Like

that is not good some display’s have touch screen use touch-enabled and keyboard enabled

1 Like

I feel like @skyblox7862’s solution is much more reliable.

2 Likes
local UserInputService = game:GetService("UserInputService")

local function checkDeviceType()
    local screenSize = workspace.CurrentCamera.ViewportSize
    if screenSize.X >= 1024 and screenSize.Y >= 768 then
        return "iPad or larger tablet"
    elseif screenSize.X >= 800 and screenSize.Y >= 480 then
        return "Phone with a larger screen"
    else
        return "Smaller phone"
    end
end

UserInputService.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Touch then
        local deviceType = checkDeviceType()
        print("User is using a " .. deviceType)
    elseif input.UserInputType == Enum.UserInputType.Keyboard then
        print("User is using a keyboard")
    end
end)

Edit: Dang, that solved was quick. Didn’t have time to dig through my stuff. My bad.

Mikhali Yes, I understand Bluestacks exists. At one time knowing this was important, I even made an offset plugin so all my GUIs would work on any screen. However while I was creating that plugin I figured out how this was really done. This is still useful for other reasons and why I had problems finding it. It is buried in my not so useful pile…

For those looking to achieve what I stared doing here, creating generic GUIs … Here is a 1:11 video on how to make your GUIs fit any device. Yes, it is short and believe it or not it actually works.
How To Make GUI Fit All Devices In Roblox Studio (Easiest Method)

In this video you will see him setting a very small GUI … more of a popup. The trick to this is, is to set every single frame, button and picture (basically anything with a size and location) the way he will show you.

10 Likes

Bluestacks exists dude did you know that

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.