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

TouchPan

The TouchPan event fires when the player moves their finger on the UI element using a touch-enabled device. It fires shortly before GuiObject/TouchSwipe would, and does not fire with GuiObject/TouchTap. This event is useful for allowing the player to manipulate the position of UI elements on the screen.

This event fires with a table of DataType/Vector2 that describe the relative screen positions of the fingers involved in the gesture. In addition, it fires several times with multiple Enum/UserInputStates: Begin after a brief delay, Change when the player moves their finger during the gesture and finally once more with End.

This event cannot be simulated in Studio using the emulator and a mouse; you must have a real touch enabled device to fire this event. Below is an animation of TouchPan firing on the black semitransparent Frame that covers the screen. The event is being used to manipulate the position of the pink inner Frame. The code for this can be found in the code samples.

TouchPan firing on a real touch-enabled device

This event is part of a family of touch-related events. Other events like this one are GuiObject/TouchTap, GuiObject/TouchRotate, GuiObject/TouchPinch, GuiObject/TouchLongPress and GuiObject/TouchSwipe. In addition, UserInputService has a similarly named event that is not restricted to a specific UI element: UserInputService/TouchPan.

Parameters

Name Type Default Description

Code Samples


Panning UI Element

This code sample is meant to be placed in a LocalScript within an inner Frame that is inside an outer Frame, or other GuiObject. It allows the player to manipulate the position of the inner frame by moving their finger on the outer frame.