How to check if a player is on mobile

Hello, I’ve never really tried adding mobile support to my game i just have a few questions and some advice to set me in the right direction:

  • I would like to know how to check if a player is on a mobile device in order to make those mobile buttons appear.

  • How I can detect if the player is holding down a button

  • How would I prevent this from looking squished (im using scale for pos and size)

(squished)
image

(normal)
image

1 Like

first, there is no official way of detecting if a player is on mobile device using Roblox APIs
but you can use UserInputService:GetLastInputType() to check if input was a from mobile of keybord

and as for UI, with detect Holding Button.InputBegan & InputEnded will work

and for squished UI i recoment always using offset for ui elements parented to the screenGui, but if you really want to use scale, UIAspectRatioConstraint will keep the shape and scaling

1 Like

A basic way to check device could be this:

local uis = game:GetService("UserInputService")

if uis.KeyboardEnabled then
    --pc
elseif uis.TouchEnabled then
    --mobile
end
4 Likes

How would I disable the jump button and move thing

Check this article out. Hope this helps!