Mobile controls implementation...?

Hi there, i am the creator of an old game called Ro-Planes 3 and my scripter is currently trying to figure out how to implement mobile controls.

My scripter is wanting to know some methods on how to determine whether a player is on Mobile/tablet instead of PC. what would be used to make this possible?
My goal is to have it where if a player joins on mobile/tablet and OnSeated in the plane they would be shown the Mobile controls UI instead of normal PC controls.

I am making this post because my scripter cannot find any information elsewhere about this.
A few friends have said something about a function called “DeviceType”…? but im not entirely sure.

His words specifically: so, basically i need to figure out how to implement functions specific to a player on PC or to players on mobile.

More explanations:

we’re trying to make a game that works for mobile AND pc right? it works very differently on PC, and for mobile so i need a way to detect if the user is on PC or mobile (which i’ve done) but idk how to create a function based on the context of if it’s PC or mobile because if it’s PC, then we can leave the layout we have but if it’s mobile, i need to implement those extra pads to do the maneuvers
does that make sense?

Maybe these can help?

Hes aware of those and they dont help much but i just edited the post with a better explanation at the bottom.

I don’t know how to do it like a function, but maybe you could try something like this?

local UIS = game:GetService("UserInputService")

if UIS.TouchEnabled then
   print("Player uses touchscreen”)
   —make mobile only ui visible
   elseif UIS.KeyboardEnabled then
   print("Player uses a keyboard.")
   —make mobile only ui not visible

I haven’t tested that yet so it might not work.

Regarding controls(PC keybinds): If you want implement those, then you would need to use Context Action Service(CAS) instead of User Input Service(UIS). The reason is that since mobile only have touch screen you would need to create a touch buttons for mobile players to use as PC keybinds. In that regard that is the only case

Regarding UI and GUI: On both of those you can use .MouseButton1Click event to know when player clicked on it, it’s cross-platform so no need to worry about it too much. If by this

you mean to show for example instead of “Click” it would be “Tap” then you can use this
It’s basically detects what Last Input of the Player was, which helps you to find out what type of controlling player uses right now. You would just need to set something(for example a StringValue in a Player or put it in a Module Table) to correspond with what type of device player is using. After that show UI input that is needed accordingly.
If you have questions then feel free to ask!

1 Like

This page has some pretty useful articles regarding mobile controls.

I’d recommend this article specifically–it gives the code to detect a user’s device.

1 Like

My scripter said hes gonna try this, ill let u know if it works out.