How to detect player using Mobile Buttons/UI

Atm I am using the Userinputservice to make a player throw something on click/tap.

My problem is how I am going to do this for mobile devices, making it ignore the moving stick and jump button along with any User interface. This is to prevent making the player throw while clicking on any UI elements.

I have gone through the wiki and tried out the TouchTapInWorld but it did not really solve my problem. Any suggestion/solution to this please?

Have you tried using properties such as UIS.MouseEnabled? It may offer a less preferable solution but it is the only viable option I can think of.


local UIS = game:GetService("UserInputService")
local GS = game:GetService("GuiService")

if not UIS.KeyboardEnabled and not UIS.MouseEnabled and not GS:IsTenFootInterface() and not UIS.GamepadEnabled and UIS.TouchEnabled then
-- mobile code
elseif UIS.KeyboardEnabled then
-- PC code

Please let me know if this answers your question or you find a solution as I am now interested as well.