Heyyy guys! How do you make the tool work when you press the mouse for a long time?
I tried to find information on it, but I couldn’t find any talking about my problem
I would use UserInputService.InputBegan and UserInputService.InputEnded. The general idea is this
local timeOfPreviousClick = -1
OnInputBegan
if Input.InputType is MouseButton1 then
timeOfPreviousClick = os.clock()
local timeOfThisClick = timeOfPreviousClick
wait(the time you wanted to wait)
if timeStarted == timeOfPreviousClick then
trigger the tool
end
end
end
OnInputEnded
timeOfPreviousClick = -1
end
so, when the user clicks, it stores the time, after waiting, if the stored time is still the same, trigger the tool
when the user clicks, and lets go, the stored time becomes -1, so after waiting in the InputBegan, it won’t trigger
when the user clicks, lets go, then clicks again, the stored time changes to the time of the second click, so the waiting in the first click won’t trigger, they’ll need to wait the holding time from the second click
what is : TimeStarted? what’s the value? because your script is making me rather confused.
your script is incomplete
mb, I meant “timeOfThisClick” instead of “timeStarted”