You can use the Activated event to check whenever a button in a Gui is clicked, no matter if the player is on PC or Mobile. Make sure that the Active property of the GuiObject is set to True for this to work.
More info about the different properties & events in this topic can be found below, just in case using Activated doesn’t match the use case for your game:
MouseButton1Click is essentially MouseButton1Up both on pc and on mobile. MouseButton1Click might have time.
The difference between MouseButton1Up and TouchTap is that MouseButton1Up will fire on mobile when releasing input regardless whether you intentionally meant to swipe or leave the gui button. That means if your finger is on the textbutton and you release that finger, that input will go through no matter what.
While TouchTap will take into consideration of that. If you put your finger on the textbutton for sometime and you release it; the input won’t go through.
MouseButton1Up is a problem on mobile because you can unintentionally click on a button when you didn’t mean to. (e.g. accidentally spending 90% of your ingame currency on something you didn’t want).
I thought this
if IsUserOnPc then
TextButton.MouseButton1Up:Connect(. . .)
elseif IsUserOnMobile then
TextButton.TouchTap:Connect(. . .)
That makes sense – I also just realized something looking back at your previous post:
I took a look at the documentation of GuiObject’s events, and it turns out that while TouchTap works for quick inputs, TouchLongPress is intended for situations where the player holds the button/GuiObject down. I’m not sure if this will be useful or not (or if you already looked over the TouchLongPress event already) but I wanted to mention it just in case it comes in handy.
Also, since you just marked my post as a solution again, for some reason it shows that I edited the post today when I haven’t edited it since making that post (not sure if that’s a discourse bug).