hello, im trying to add mobile support to my game, and its not working properly
basically what im trying to do is make it so that if you hold your finger for 0.5 on one spot we start visualizing
it should ignore all other inputs that arent that; so for instance we can move, hold a finger and then start visualizing, or hold a finger, start visualizing and then move, i hope you get the idea
local inputChanged, inputEnded
local activeTouch = nil
local holding = true
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.Touch and not activeTouch then
local startPos = input.Position
holding = true
activeTouch = input
task.delay(HOLD_TIME, function()
if holding then
local touchPos = startPos
Visualizer:Begin()
end
end)
inputChanged = UserInputService.InputChanged:Connect(function(moveInput)
if moveInput == activeTouch then
local moved = (moveInput.Position - startPos).Magnitude
if moved > MOVE_THRESHOLD then
holding = false
end
end
end)
inputEnded = UserInputService.InputEnded:Connect(function(endInput)
if endInput == activeTouch then
fire()
activeTouch = nil
holding = true
if inputChanged then inputChanged:Disconnect() end
if inputEnded then inputEnded:Disconnect() end
end
end)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
Visualizer:Begin()
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
fire()
end
end)```
** You are now Level 3! **