Know if player is still touching a mobile button

I don’t know how to detect if a player stopped touching a Context Action Service mobile button, for my FPS, it’s already adapted to console but can’t get working the automatic gun fire for mobile

Also would like to know if copying the button and positioning it on the left side of the screen would still work for the binded action, to make a left fire button

Checking for Enum.UserInputState.End can give you an idea of when a player stop touching their screen, but the catch with that on a touch-enabled device versus other platforms is that a player can be firing multiple touch events at once. From my experience, there is no easy way to distinguish, say, a “shooting” finger leaving the touchscreen versus a “camera panning” finger leaving the touchscreen using ContextActionService, because that service generates a new InputObject with every state change.

While it is annoying, UserInputService’s very basic input-handling events (InputBegan, InputChanged, and InputEnded) DO use the same InputObject for state changes on a single touch. While you will need to do more input filtering with this, it does mean that you can distinguish between different touch inputs, save them to variables, and subsequently run logic for whichever input is being modified independent of each other. This difference is why the older thumbstick control is more reliable than the newer dynamic thumbstick in a lot of circumstances: the former uses UserInputService, whereas the latter users ContextActionService to handle input.

1 Like

To follow up on this a bit, I’ve gone in and done a little bit of further testing:

UserInputService’s touch-specific event also maintain the aforementioned single-object behavior. This means you can code your project specifically to handle touch input without having to catch everything and filter it. I apologize for any confusion I may have caused.

2 Likes