Skip to content

Mobile

The Mobile module exposes events related to mobile input.


Obtain Mobile

1
local mobile = userInput:Get("Mobile")

Methods

GetDeviceAcceleration()

Get the acceleration of the device.

1
local acceleration = mobile:GetDeviceAcceleration()

GetDeviceGravity()

Get the gravitational force on the device.

1
local gravity = mobile:GetDeviceGravity()

GetDeviceRotation()

Get the rotation of the device.

1
local rotation, cframe = mobile:GetDeviceRotation()

Events

TouchStarted

Fires when a touch is started.

1
2
3
mobile.TouchStarted:Connect(function(screenPosition)
    print("TouchStarted", screenPosition)
end)

TouchEnded

Fires when a touch ends.

1
2
3
mobile.TouchEnded:Connect(function(screenPosition)
    print("TouchEnded", screenPosition)
end)

TouchMoved

Fires when a touch moves.

1
2
3
mobile.TouchMoved:Connect(function(screenPosition, deltaPosition)
    print("TouchMoved", screenPosition, deltaPosition)
end)

TouchTapInWorld

Fires when a touch tap is registered in the 3D world.

1
2
3
mobile.TouchTapInWorld:Connect(function(position)
    print("TouchTapInWorld", position)
end)

TouchPinch

Fires when a touch pinch is registered.

1
2
3
mobile.TouchPinch:Connect(function(touchPositions, scale, velocity, state)
    print("TouchPinch", touchPositions, scale, velocity, state)
end)

TouchLongPress

Fires when a long press is registered.

1
2
3
mobile.TouchLongPress:Connect(function(touchPositions, state)
    print("TouchLongPress", touchPositions, state)
end)

TouchPan

Fires when a pan is registered.

1
2
3
mobile.TouchPan:Connect(function(touchPositions, totalTranslation, velocity, state)
    print("TouchPan", touchPositions, totalTranslation, velocity, state)
end)

TouchRotate

Fires when a rotation is registered.

1
2
3
mobile.TouchRotate:Connect(function(touchPositions, rotation, velocity, state)
    print("TouchRotate", touchPositions, rotation, velocity, state)
end)

TouchSwipe

Fires when a swipe is registered.

1
2
3
mobile.TouchSwipe:Connect(function(swipeDirection, numberOfTouches)
    print("TouchSwipe", swipeDirection, numberOfTouches)
end)

See SwipeDirection for possible values.


TouchTap

Fires when a tap is registered.

1
2
3
mobile.TouchTap:Connect(function(touchPositions)
    print("TouchTap", touchPositions)
end)

DeviceAccelerationChanged

Fires when the device's acceleration changes.

1
2
3
mobile.DeviceAccelerationChanged:Connect(function(acceleration)
    print("DeviceAccelerationChanged", acceleration)
end)

DeviceGravityChanged

Fires when the device's gravitational pull changes.

1
2
3
mobile.DeviceGravityChanged:Connect(function(gravity)
    print("DeviceGravityChanged", gravity)
end)

DeviceRotationChanged

Fires when the device's rotation changes.

1
2
3
mobile.DeviceRotationChanged:Connect(function(rotation, cframe)
    print("DeviceRotationChanged", rotation, cframe)
end)