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:
This property determines whether a GuiObject will sink input to 3D space
It seems like it could work, both the wiki and the devforum post doesn’t clarify fully what inputs .Activate takes.
Never mind, the script takes TouchTap as an event handler
TouchTap Roblox wiki
Since this event only requires one finger, this event can be simulated in Studio using the emulator and a mouse. Below is an example of TouchTap being fired on a Frame that is GuiObject.Active
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(. . .)
end
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.
Unrelated note:
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).