Mobile/ipad Multitouch scripting examples or tutorials

Late response, but this may be useful for anyone with a similar issue.

The structure of the documentation makes it difficult to find, but we can read in UserInputService | Roblox Creator Documentation that a unique touch will always use the same InputObject instance for all of its events. (This is also true for all other inputs, as noted on the InputObject page.)

This means if you get a touch input, you can store a reference to its InputObject, and when handling later inputs can compare your stored InputObjects with those later InputObjects to see if it is the same touch.

For example:

local firstTouch

userInputService.TouchStarted:Connect(function(inputObject)
   if (not firstTouch) or (firstTouch == inputObject) then
      firstTouch = inputObject
      print("First touch started")
   else
      print("A different touch started")
   end
end)

userInputService.TouchEnded:Connect(function(inputObject)
   if firstTouch == inputObject then
      print("First touch ended")
      firstTouch = nil
   else
      print("A different touch ended")
   end
end)
7 Likes