I want to get device’s orientation accurately.
I tried to use this script:
local Service = game:GetService('UserInputService')
if Service.GyroscopeEnabled then
Service.DeviceGravityChanged:Connect(function(acceleration)
script.Parent.Background.Arrow.Rotation = acceleration.Position.Y
end)
else
game:GetService('Players').LocalPlayer:Kick('Your device does not support compass or you need to enable location or sensors on Roblox app permissions from device settings!')
end
It’s not getting the device’s orientation properly!
Is there a another script I can try?
Yes I have also looked into DeviceRotationChanged, but in my scripts, I get the CFrame.Position.Y from the DeviceRotationChanged and it didn’t work.
I want to make a Gui that is similar to a compass.
You could use the ScreenOrientation property of PlayerGui. If you want to know when the orientation changes then you can do PlayerGui:GetPropertyChangedSignal("ScreenOrientation"):Connect()
local uis = game:GetService("UserInputService")
while wait(0.2) do
if uis.GyroscopeEnabled then
local np, deviceCFrame = uis:GetDeviceRotation()
--now you have device orientation. Its a CFrame.
end
end