I have a tool where you can hold it down to continue using it repeatedly. It works like this: when Tool.Activated is fired, it sets a variable called using to true. After the tool does it’s action, it checks if using is true, and if so, fires tool:Activate() again. When Tool.Deactivated is fired, it sets using to false.
It works well except for the edge case described in the title. How can I fix this in a way that will work on both mobile and desktop?
I fixed it by creating this connection when the tool is equipped, and disconnecting it when the tool is unequipped:
inputListener = userInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType==Enum.UserInputType.Touch then
using = false
else
using = true
end