Can't get GUI touch detection to work on mobile

Hey fellow developer forum members!

I came across a issue when trying to make my game mobile compatible.

I can’t get gui touch detection on my TextButton to work.

I have tried using .Activated and .MouseButton1Down, but still no success.

For some reason the events won’t fire when I press the button no matter what technique I use.

My code is perfect, the events just won’t fire on mobile for some reason.

Anyone got any ideas?

1 Like

MouseButton1Down requires a mouse and won’t activate on mobile devices or on Xbox.

Use: Button.Activated:Connect() - you said it wasn’t working, are there any errors in output/developer console?

Also, is this a GUI in PlayerGui or a BillboardGui/SurfaceGui or something?

I know this already, I only tried MouseButton1Down because I tried using Activated already.

There is no output or console errors.

It is inside of a Frame inside a ScreenGui.

I also made sure that the Active property of the Button was true.

Think you might need to use the ContextActionService and the UserInputService for this problem. I don’t really have any experience working with mobile devices, but this seems to be the only way to make something mobile compatible.

How would I use ContextActionService to detect if a specific button is being pressed, not just the entire screen?

Never mind, I did some digging in the API and it turns out its pretty simple. There’s an event called InputBegan for GUI objects that returns input. Here’s a link to the article

1 Like

Yay! This is working for me. Thanks so much @bilalthedestroyer! :smiley:

1 Like