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.

1 Like
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.

7 Likes

Bluestacks exists dude did you know that

1 Like

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