Can custom GUI buttons be made mobile compatible?

Hello.
I am currently trying to implement a button without relying on TextButton. (I mainly use Labels).
Currently, I am able to control it on a PC using MouseEnter, but of course I cannot control it on a mobile because there is no mouse.
(The reason I don’t use the TextButton is that it doesn’t respond when InputEnded when the cursor is away from the button.)
At the moment I don’t know the API that corresponds to the Touch version of MouseEnter, so I can’t determine if the touched location is on a custom button.
Any advice would be appreciated.
I am attaching the current script for reference.

tbutton.MouseEnter:Connect(function()
	on.Value = true
end)
button.MouseLeave:Connect(function()
	on.Value = false
end)

UIS.InputBegan:Connect(function(input,gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if on.Value == true then
			hold.Value = true
		end
	end
end)

UIS.InputEnded:Connect(function(input,gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		hold.Value = false
	end
end)

You Can Use These Events for mobi;e

image

1 Like

I don’t see the need to create a custom GUI button system when the Active property exists. All GUI Instances that inherit from the GuiObject class can receive input if you set their Active property to true and use either the InputBegan, InputChanged, InputEnded or the touch events that MeTooIDK suggested. TextLabels inherit from GuiObject so by following these steps you can easily make them work as a button

Roblox even added the GuiState property recently which changes to Press when a player activates the GUI:

1 Like

Thanks for the reply.
We were finally able to create exactly what we wanted using TouchTap.
I also learned for the first time that it does not respond if the Active property is not checked.:sweat_smile:

1 Like

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