Ignore joystick when using UserInputService.TouchLongPress

How would I go about ignoring the joystick being touched by a left thumb to move my character when using UserInputService.TouchLongPress to detect the rest of the screen being pressed by the right thumb at the same time?

2 Likes

According to the wiki, UserInputService.TouchLongPress returns a third parameter called gameProcessedEvent. The parameter is true if the touch was on a UI element (which should include the joystick), so have your script check if that parameter is false.

Example:

local userInputService = game:GetService("UserInputService")
 
function TouchLongPress(TouchPositions, state, gameProcessedEvent)
	if (gameProcessedEvent == false) then
       --script would continue here
    end
end
 
userInputService.TouchLongPress:Connect(TouchLongPress)
1 Like