Collapse Sidebar


The TouchTapInWorld event fires when the user touches/taps their finger on the screen on a UserInputService/TouchEnabled|TouchEnabled device. It is fired when the user taps in the game world.

This event can be used to determine when a user taps the screen and does not tap a GuiObject|GUI element. If the user taps a GUI element, UserInputService/TouchTap will fire instead of TouchTapInWorld.

To check if a user’s device is TouchEnabled, and that touch events will fire, see UserInputService/TouchEnabled.

This event only fires when the Roblox client window is in focus. For example, inputs will not be captured when the window is minimized.

As it only fires locally, it can only be used in a LocalScript.

See also

  • UserInputService/TouchTap
  • UserInputService/TouchLongPress
  • UserInputService/TouchMoved
  • UserInputService/TouchPan
  • UserInputService/TouchPinch
  • UserInputService/TouchRotate
  • UserInputService/TouchSwipe
  • UserInputService/TouchStarted
  • UserInputService/TouchEnded


Name Type Default Description

A DataType/Vector2 indicating the position of the touch

Whether the user tapped a GUI element

Code Samples

Create a Part in World at Touch Position

This example uses the DataType/Vector2|Vector2 position passed by UserInputService/TouchTapInWorld|TouchTapInWorld to find the DataType/Vector3|Vector3 world position the user tapped. Then, the code spawns an anchored BasePart|Part at the world position.

In order to calculate the DataType/Vector3|Vector3 world position using the viewport position, this example generates a Ray called unitRay originating from position using the Camera/ViewportPointToRay|ViewportPointToRay function. Then, since ViewportPointToRay() creates a unit ray that is only 1 stud long, the example uses it to create a longer ray that is length studs long. Using Workspace/FindPartOnRay|FindPartOnRay, the code determines where the ray first intersects a part in the world - the Vector3 world position that the user tapped.

Note that the code sample will not spawn a part if the user touches on the screen over an empty skybox. The touch must be on a part for FindPartOnRay() to return a DataType/Vector3|Vector3 position.