Userinputservice sometimes doesn't detect the mobile users

My game requires you to use keys like Q, 2, E, R. Since mobile users can’t use these, I made a system for them that allows them to tap the abilities in order to use them. I called it “TapMode” and made it so it gets enabled with a localscript inside the GUI. The script basically detects if they have touch mode enabled and switches the mode. However, I’m 100% sure that the script rarely fails to detect it. What could be the reason? Since it happens very rarely, I can’t check the output too.

`local UserInputService = game:GetService(“UserInputService”)

if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled then

script.Parent.Parent.Abilities.Taunt.Visible = true

script.Parent.Position = script.Parent.Position - UDim2.new(0,0,0.41,0)

script.Parent.Parent.Abilities.KingsWrath.Position = script.Parent.Parent.Abilities.KingsWrath.Position - UDim2.new(0,0,4.1,0)

script.Parent.Parent.Stats.Position = script.Parent.Parent.Stats.Position - UDim2.new(0,0,0.41,0)

script.RemoteEvent:FireServer()

end`

Should I only be checking for TouchEnabled?

It’s possible that the script is failing to detect the touch mode because it’s checking for the TouchEnabled property of the UserInputService object, but not checking for the GamepadEnabled property. It’s also possible that the script is checking for the KeyboardEnabled and MouseEnabled properties, but not for the MouseSupportsNativeZone property. I would recommend adding checks for these properties to your script to ensure that it properly detects touch mode.

Additionally, it’s worth noting that there may be other factors that could cause the script to fail, such as network issues or server-side problems. If the issue persists, it would be a good idea to add some logging to the script to help diagnose the problem.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.