TouchStarted
For thread safety, this property is not safe to read in an unsynchronized thread.
The TouchStarted event fires when a user places their finger on a UserInputService/TouchEnabled|TouchEnabled device, beginning touch input with the device.
This event can be used to determine when a user starts touching the screen of their device. It can be paired with UserInputService/TouchEnded to determine when a user starts and stops touching the screen.
The touch input object is the same input object throughout the lifetime of the touch. So comparing InputObject|InputObjects when they are touch objects is valid to determine if it is the same finger.
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 this event only fires locally, it can only be used in a LocalScript.
See also
UserInputService/TouchTapUserInputService/TouchTapInWorldUserInputService/TouchLongPressUserInputService/TouchMovedUserInputService/TouchPanUserInputService/TouchPinchUserInputService/TouchRotateUserInputService/TouchSwipeUserInputService/TouchEnded
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
An |
||
|
|
Indicates whether the game engine internally observed this input and acted on it. Generally this refers to UI processing, so if a button was touched or clicked from this input, |
Code Samples
Tracking Touches
This example demonstrates how to use touch input events to drag a GUI element while a player touches and drags across their screen.
The touch InputObject is the same input object throughout the lifetime of the touch. So comparing input objects when they are touch objects is valid to determine if it is the same touch as the input starts, changes, and ends.
The example starts tracking a drag once the touch is registered by the UserInputService/TouchStarted|TouchStarted event. It continues to update as that touch moves, tracking it’s position relative to start position to move a GUI until a UserInputService/TouchStarted|TouchEvent event fires for that touch.