So if the user is using a computer, they can't use the script, but if the user is using a phone, then they can.
If someone could atleast guide me in the right direction, that would be great.
function setKey(input) if input.KeyCode == Enum.KeyCode.A then
I'm guessing something like this could help.
To continue on @Leamir's code, you can also detect if KeyboardEnable is false and MouseEnable just in case their computer is a touch screen!
local UIS = game:GetService("UserInputService") local GuiService = game:GetService("GuiService") if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled then -- mobile device end
https://developer.roblox.com/en-us/api-reference/property/UserInputService/MouseEnabled
https://developer.roblox.com/en-us/api-reference/property/UserInputService/TouchEnabled
https://developer.roblox.com/en-us/api-reference/property/UserInputService/KeyboardEnabled
You can't do exactaly that, but you can detect if user have touch enabled on his/her device.
local userInputService = game:GetService("UserInputService") if userInputService.TouchEnabled then print("The user's device has a touchscreen!") else print("The user's device does not have a touchscreen!") end
(extracted from https://developer.roblox.com/en-us/api-reference/property/UserInputService/TouchEnabled)
Wow. Thanks guys ^^
It managed to fix my issue.
I actually hope this helps others too, if they had a similar problem.