My UI is not working on mobile

Hello my teleport system is not working on mobile devices but its working on pc

i used input service instead of mousebuttonclick here is the script:

image

Can someone knows how can i fix this problem ?

i dont know that the full code is because it is a screenshot instead of a messy text or at least a codeblock but I know its in that if statement

if Input.UserInputType == Enum.UserInputType.MouseButton1 or 
Input.UserInputType == Enum.UserInputType.Touch then 
-- you dont need userinputstate

-- or do it like this
if 
	Input.UserInputState == Enum.UserInputState.Begin and
	(Input.UserInputType == Enum.UserInputType.MouseButton1 or 
	Input.UserInputType == Enum.UserInputType.Touch)
then


fixed line

if Input.UserInputState == Enum.UserInputState.Begin and (Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch or Input.KeyCode == Enum.KeyCode.ButtonA) then

I tried the script but thats didnt worked too

Do you really need to use UIS or you can use other choices but chose not to ?

Yes I need to make UI to make teleport system of course , mousebutton is not working either

This looks like it would teleport you every time you click, are you trying to teleport the player when they click a button? By the way, this code will error if the player’s character is nil.

What do you mean by “not working”? Have you tried adding a print line to the function?

Button.MouseButton1Click:Connect(function()
    print('click')

    -- teleport code
end)
1 Like