The TouchEnded event fires when a user released their finger from the screen of a TouchEnabled device, ending touch input with the device.
This event can be used to determine when a user stops touching the screen of their device. It can be paired with
UserInputService/TouchStarted to determine when a user starts and stops touching the screen.
For example, the code below prints the screen position where the user stops touching the screen.
local UserInputService = game:GetService("UserInputService") function TouchEnded(touch, gameProcessedEvent) print("Touch ended at "..tostring(touch.Position)) end UserInputService.TouchEnded:Connect(TouchEnded)
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
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
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,
The Difference Between TouchTap and TouchLongPress
The code sample below demonstrates the difference between a
UserInputService/TouchLongPress|TouchLongPress by creating a
Frame that appears when user touches the screen of their device and disappears when the
UserInputEvent/TouchEnded|touch ends. When the long press event fires, the GUI doubles in size. Also, the GUI moves to stay centered under the user’s finger when the player moves their finger.
In order for the
UserInputService/TouchLongPress|TouchLongPress to fire, the user touch the screen and hold their finger still for a short period of time. Once the touch moves, the long press event will not fire.
In order for the example to work as expected, it should be placed in a
LocalScript that is parented to a