We use cookies on this site to enhance your user experience
Collapse Sidebar


The TouchSwipe event fires when a user swipes their fingers on a UserInputService/TouchEnabled|TouchEnabled device.

This event can be used to determine when a user swipes their fingers on the screen of their device and the direction that the user swiped.

For more precise tracking of touch input movement, use using UserInputService/TouchMoved

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/TouchTap
  • UserInputService/TouchTapInWorld
  • UserInputService/TouchLongPress
  • UserInputService/TouchMoved
  • UserInputService/TouchPan
  • UserInputService/TouchPinch
  • UserInputService/TouchRotate
  • UserInputService/TouchStarted
  • UserInputService/TouchEnded


Name Type Default Description

An `Enum/SwipeDirection, indicating the direction the user swiped


Number of touches (e.g. fingers) involved in the gesture

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, gameProcessedEvent would be true. This is also true for input events connected via ContextActionService

Code Samples

Touch Swipe a GUI

The example below demonstrates the UserInputService/TouchSwipe|TouchSwipe event by GuiObject/TweenPosition|tweening a GuiObject|GUI element’s position 100 pixels in the direction of the swipe according to the value of the Enum/SwipeDirection|swipeDirection argument.

In order for this example to work as expected, it must be placed in a LocalScript that is parented to the gui being swiped.

local UserInputService = game:GetService("UserInputService")

local gui = script.Parent
local swipePositionY = gui.Position.Y.Offset
local swipePositionX = gui.Position.X.Offset

local camera = game.Workspace.CurrentCamera
local maxY = camera.ViewportSize.Y - gui.Size.Y.Offset
local maxX = camera.ViewportSize.X- gui.Size.X.Offset

local function TouchSwipe(swipeDirection, numberOfTouches, gameProcessedEvent)
	if swipeDirection == Enum.SwipeDirection.Up then
		swipePositionY = math.max(swipePositionY-200, 0)
	elseif swipeDirection == Enum.SwipeDirection.Down then
		swipePositionY = math.min(swipePositionY+200, maxY)
	elseif swipeDirection == Enum.SwipeDirection.Left then
		swipePositionX = math.max(swipePositionX-200, 0)
	elseif swipeDirection == Enum.SwipeDirection.Right then
		swipePositionX = math.min(swipePositionX+200, maxX)
	gui:TweenPosition(UDim2.new(0, swipePositionX, 0, swipePositionY), "Out", "Quad", .25, true)