The soloution to your answer.
GetDeviceAcceleration
The GetDeviceAcceleration function determines the current acceleration of the user’s device. It returns an InputObject
that describes the device’s current acceleration.
In order for this to work, the user’s device must have an enabled accelerometer. To check if a user’s device has an enabled accelerometer, you can check the UserInputService.AccelerometerEnabled
property.
If you want to track when the user’s device’s acceleration changes instead, you can use the UserInputService.DeviceAccelerationChanged
event.
Since it only fires locally, it can only be used in a LocalScript
.
GetDeviceRotation
This function returns an InputObject
and a CFrame
describing the device’s current rotation vector.
This is fired with an InputObject. The Position property of the input object is a Enum.InputType.Gyroscope
that tracks the total rotation in each local device axis.
Device rotation can only be tracked on devices with a gyroscope
.
As this function fires locally, it can only be used in a LocalScript
.
GetDeviceGravity
This function returns an InputObject
describing the device’s current gravity vector.
The gravity vector is determined by the device’s orientation relative to the real-world force of gravity. For instance, if a device is perfectly upright (portrait), the gravity vector is Vector3.new(0, 0, -9.18)
. If the left side of the device is pointing down, the vector is Vector3.new(9.81, 0, 0). Finally, if the back of the device is pointing down, the vector is Vector3.new(0, -9.81, 0).
This function might be used to enable the user’s device to impact or control gravity within the game or move in-game objects such as a ball.
Gravity is only tracked for players using a device with an enabled gyroscope - such as a mobile device.
To check if a user’s device has an enabled gyroscope, check the value of UserInputService.GyroscopeEnabled
. If the device has an enabled gyroscope, you can also use the UserInputService.DeviceGravityChanged
event to track when force of gravity on the user’s device changes.
As UserInputService
is client-side only, this function can only be used in a LocalScript
.
Source:
https://developer.roblox.com/en-us/api-reference/class/UserInputService
I hope this helps and have a good day!
DM me if you have any questions!