TextButton not working on mobile?

  1. What do you want to achieve? I want this script to print a certain phrase however it does not seem to work on mobile for whatever reason.

  2. What is the issue? Mobile users can’t interact with the textbutton but they can with other on the screen.

  3. What solutions have you tried so far? Tried InputBegan and didn’t work either.

The reason it’s in playergui because when a mobile player equips it’s parented to PlayerGui and later parents back to “script” when unequipped.

local gui = Player.PlayerGui:WaitForChild("Mobile"):WaitForChild("StompButton")
if gui then
	print(gui)
	gui.MouseButton1Click:Connect(function()
		print("DF1")
		if Downed.Value == false then
	          print("DF2")
		end
	end)
	else return 
end```

Your using gui.MouseButton1Click, use .Activated instead.

Nope. Still doesn’t work. It’s only print the gui name.
image

You should try using .MouseButton1Down instead, and see if that fixes it

Well that worked… I don’t know why Activated doesn’t work considering it’s touch friendly.

local gui = Player.PlayerGui:WaitForChild("Mobile"):WaitForChild("StompButton")

Also, you don’t need to check if gui exists, it won’t run the code anyway since it will infinitely yield IF it doesn’t find it

gui.MouseButton1Click:Connect(function()
	if Downed.Value == false then
       -- run code
	end
end)

Just have this only, more readable

.Activated only works on tools, so unless you check if the tool is activated it won’t run

1 Like

.Activated works on gui buttons and tools not just tools
GuiButton.Activated (roblox.com)