How to implement a 'Hold Mouse 1' feature to Mobile?

I’ve made a combat game that relies on holding mouse 1 to charge up your attack and realized that trying it on mobile would not work at all. I’ve tried to watch how to maybe add a button to solve this but none really covered on how to do a Mouse 1 Hold button specifically. Do I have to make an actual GUI button and script to be able to hold on mobile? Or is it a bit more simpler or complicated than that? I’ll keep trying in the mean time and thank you for reading.

You could use the “ContextActionService” to create a button on mobile devices. A button will appear on a mobile device automaticaly if the third arg is true.

Heres a small example on how to use it:

local IsDown = false
local Service = game:GetService("ContextActionService")

local function DoStuff(Action,State,Input) -- Action pretty clear. The action you bound to the func, State. Returns "Begin" when it detects an input. Returns "End" when the input has ended
	if Action == "YourActionName" and State == Enum.UserInputState.Begin then
		IsDown = true
	elseif Action == "YourActionName" and State == Enum.UserInputState.End then
		IsDown = false

Service:BindAction("YourActionName",DoStuff,true,Enum.KeyCode.R) -- // ActionName,Your callback,Should create button on mobile,Input type for desktop. Im going to go with the key "R" as my input

-- // Customization for the button

Oh yeah, that might be the case. I will try to look deeper into ContextActionService and see if it will work, I’ll go test it out now. Thank you!

Enum.UserInputType.Touch would be the equivalent input for touchscreen devices.