Hello, I have a helicopter and I want it to tilt using bodygyro, but the values are all messed up and I don’t know what to do to fix it.
For example, I want it to have the orientation -20, 50, 20 it instead will have the orientation -20, 0, 180.
if StartUp == true then
if Seat.Throttle == 1 then
local x, y, z = BodyGyro.CFrame:ToEulerAnglesXYZ()
BodyGyro.CFrame = CFrame.Angles(math.rad(-20), math.rad(math.deg(y)), math.rad(math.deg(z)))
while Seat.Throttle == 1 do
local velocity = Helicopter.Body.CFrame.LookVector * Speed.Value
BodyVelocity.Velocity = Vector3.new(velocity.X, BodyVelocity.Velocity.Y, velocity.Z)
task.wait()
end
elseif Seat.Throttle == 0 then
local x, y, z = BodyGyro.CFrame:ToEulerAnglesXYZ()
BodyGyro.CFrame = CFrame.Angles(0, math.rad(math.deg(y)), math.rad(math.deg(z)))
BodyVelocity.Velocity *= Vector3.new(0, 1, 0)
elseif Seat.Throttle == -1 then
local x, y, z = BodyGyro.CFrame:ToEulerAnglesXYZ()
BodyGyro.CFrame = CFrame.Angles(math.rad(20), math.rad(math.deg(y)), math.rad(math.deg(z)))
while Seat.Throttle == -1 do
local velocity = Helicopter.Body.CFrame.LookVector * -Speed.Value
BodyVelocity.Velocity = Vector3.new(velocity.X, BodyVelocity.Velocity.Y, velocity.Z)
task.wait()
end
end
end
end)
Seat:GetPropertyChangedSignal("Steer"):Connect(function()
if StartUp == true then
if Seat.Steer == 1 then
while Seat.Steer == 1 do
local x, y, z = BodyGyro.CFrame:ToOrientation()
BodyGyro.CFrame = CFrame.Angles(math.rad(math.deg(x)), math.rad(math.deg(y)), math.rad(20))
BodyGyro.CFrame *= CFrame.Angles(0, math.rad(-1), 0)
task.wait(0.01)
end
elseif Seat.Steer == 0 then
local x, y, z = BodyGyro.CFrame:ToOrientation()
BodyGyro.CFrame = CFrame.Angles(math.rad(math.deg(x)), math.rad(math.deg(y)), 0)
elseif Seat.Steer == -1 then
while Seat.Steer == -1 do
local x, y, z = BodyGyro.CFrame:ToOrientation()
BodyGyro.CFrame = CFrame.Angles(math.rad(math.deg(x)), math.rad(math.deg(y)), math.rad(-20))
BodyGyro.CFrame *= CFrame.Angles(0, math.rad(1), 0)
task.wait(0.01)
end
end
end
end)
Here is a video of how it acts:
How can I fix this? I tried everything I could think of and I still don’t know how to solve it