Register click on mobile and mousebutto

Hey, I recently stumbled on a problem.

I have used something like MouseButton1Click etc. for all my buttons and GUIs. And it also worked with mobile, but I read that it can be buggy or shoudnt really be used for Buttons on phone.

So is there any like double-action function that registers both mousebutton1Click and mobile touch tap/click?

Is there a function? If no, how would I do it then?

1 Like

You could possibly use UserInputService’s TouchTap function.

1 Like

Does that register mouseclicks and mobile phone/ipad etc. touch/clicks also?

No, only if they register as a TouchEnabled device.

But how would I register both then? Do I need 2 separate functions :confused:

No, I don’t believe so. MouseButton1Click should work fine for both PC and Mobile. For the example I showed above, that would mostly be used for making certain gui for Mobile, but could possibly be used.

Check out the amazing service that is ContextActionService
You can bind many different inputTypes to one action while also taking advantage of some of the other benefits ContextActionService gives you.

EDIT:
While ContextActionService is useful for scripting multi-platform mechanics, for GuiButtons it may be as simple as listening for the Activated event rather than the MouseButton1Click event. Activated is already multi-platform friendly.

5 Likes