ContextActionService or Gui buttons for mobile support?

Is it better to use ContextActionService for mobile support, or make a gui with buttons?

I’ve never used contextactionservice for this kind of idea, which is why I do not see why you would use it. My opinion would just to make custom gui coded in a way that detects the players kind of input and go from there.

One more thing, I need to be able to steer a helicopter on mobile too. How the steering works is, you click and hold and the helicopter aims wherever your cursor is. Whenever I press a TextButton it doesn’t override me tapping the screen. Is there anyway to fix that?

It depends in what you feel more comfortable with.

I often interchange UserInputService and ContextActionService (which I probably am not supposed to do) depending on how I’m feeling with my code. ContextActionService will usually be my chief thought when it comes to making actions work with multiple input types. Gui buttons for activating actions I will always do manually rather than use the built-in action buttons feature.

Your needs will change depending on what specifically you are doing. It is unclear what you are currently asking this for, as in what you are wanting to make supported with mobile, but let’s try clearing that off the table first before we think about one or the other.

Personally I prefer custom gui buttons because the button position and size is just dumb imo (and it doesn’t look good)

First it is there (half out of the screen)

Then behind the jump button

Makes no sense at all. I could use ContextActionService:SetPosition but the button would be too small then.

I always believed that ContextActionService handled mobile input better than UserInputService, but it looks like they just have similar capabilities. I’ll look into it on my own.

Edit: From the Developer Hub:

Keyboardless Input

ContextActionService is especially useful for supporting gamepad and touch input. For gamepad input, you might choose to bind the B button to an action that returns the user to the previous menu when they entire another menu. For touch, on-screen touch buttons can be used in place of key presses: these buttons display only while the action is bound, and the position, text and/or images of these buttons can be configured through this service. They are somewhat limited in the amount of customization provided by this service; it’s usually a better idea to make your own on-screen buttons using ImageButton or TextButton .

So it looks like ContextActionService is the better way to go for mobile or gamepad input, whereas UserInputService can be easily used for keyboard input.

1 Like