Hello,
How would you go around creating a hold to press system on a touch device without having to wait for the TouchLongPress to fire?
You can find my full explanation on this thread : Touch Hold User Input
Hello,
How would you go around creating a hold to press system on a touch device without having to wait for the TouchLongPress to fire?
You can find my full explanation on this thread : Touch Hold User Input
Preferably with ContextActionService you’d use a boolean which is set true when the state is Begin and false when the state is End. Within your if statement scope for if the state is Begin I’d wait for how long you’d like and then if the boolean is still true then run whatever you need to.
Short example:
--// Dependencies
local ContextActionService = game:GetService("ContextActionService");
--// Constants
local WAIT_TIME = 3;
local BIND_NAME = "LONG_TOUCH";
local BIND_INPUT = Enum.UserInputType.Touch;
--// Variables
local IsDown = false;
--// Functions
local function Touch(_, State)
if (State == Enum.UserInputState.Begin) then
IsDown = true;
wait(WAIT_TIME);
if (IsDown) then
--// Code
end
elseif (State == Enum.UserInputState.End) then
IsDown = false;
end
end
--// Binds
ContextActionService:BindAction(BIND_NAME, Touch, false, BIND_INPUT);
I will give this a try very soon as I am on phone atm. Thank you so much for replying.