So i'm trying to build an airplane, obviously.I have it so it will roll with the use of the "a" and "d" keys, but when I try to have move the nose up or down or left or right, (all relative the the orientation of the plane) by using the mouse, it won't work.
xx = script.Parent.Parent.X
yy = script.Parent.Parent.Y
tool = script.Parent
typex = script.Parent:WaitForChild("type")
local plr = game.Players.LocalPlayer
local mou = plr:GetMouse()
fliers = {}
tabnum = 0
on = false
heliStor = script:WaitForChild("helinum")
heliType = script.Parent:WaitForChild("type")
for i,v in ipairs (workspace:GetChildren()) do
if v.Name == heliType.Value then
if v.pilot.Script.heli.Value == heliStor.Value then
engin = v.engine
end
end
end
bv = engin.BodyVelocity
bg = engin.BodyGyro
while true do
wait()
bg.cframe = bg.cframe * CFrame.fromEulerAnglesXYZ(xx.Value,yy.Value,0)
end
That doesn't work but the code for rolling works, (Also has other important detail I guess)
if on == true and value1 > 100 and ful.Value > 0 then
script.LocalScript.Disabled = false
else
script.LocalScript.Disabled = true
end
key = true
while key == true do
wait(0.01)
if typex.Value == "H-12 Fighter Jet" then
if ful.Value >0 then
if ky == "a" then
if on == false then
print("Engine off.")
else
if on == true and value1 > 100 and ful.Value > 0 then
bg.cframe = bg.cframe * CFrame.fromEulerAnglesXYZ(0,0,0.125)
end
end
elseif ky == "s" then
if on == false then
print("Engine off.")
else
value1 = value1-1
bv:findFirstChild("speed").Value = value1
end
elseif ky == "d" then
if on == false then
print("Engine off.")
else
if on == true and value1 > 100 and ful.Value > 0 then
bg.cframe = bg.cframe * CFrame.fromEulerAnglesXYZ(0,0,-0.125)
end
end
and if this might be any help, the code for using the mouse position
wait(2)
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
wait()
print(Mouse.X, Mouse.Y)
print(Mouse.ViewSizeX, Mouse.ViewSizeY)
local halfx = (Mouse.ViewSizeX / 2)
local halfy = (Mouse.ViewSizeY / 2)
xx = Player.Backpack.ChinookFly.X
yy = Player.Backpack.ChinookFly.Y
while true do
wait()
xoff = script.Parent.X.Value
yoff = script.Parent.Y.Value
if Mouse.X > halfx then
script.Parent.xaxis.xmark.Position = UDim2.new(0, Mouse.X-xoff, 0, 0)
raw = Mouse.X - halfx
ang = ((raw/Mouse.ViewSizeX))*0.875
xx.Value = ang
end
if Mouse.X < halfx then
script.Parent.xaxis.xmark.Position = UDim2.new(0, Mouse.X-xoff, 0, 0)
raw = halfx - Mouse.X
ang = ((raw/Mouse.ViewSizeX))*0.875
xx.Value = -ang
end
if Mouse.Y > halfy then
script.Parent.yaxis.ymark.Position = UDim2.new(0, 0, 0, Mouse.Y-yoff)
raw = halfy - Mouse.Y
ang = ((raw/Mouse.ViewSizeY))*0.875
yy.Value = ang
end
if Mouse.Y < halfy then
script.Parent.yaxis.ymark.Position = UDim2.new(0, 0, 0, Mouse.Y-yoff)
raw = Mouse.Y - halfy
ang = ((raw/Mouse.ViewSizeY))*0.875
yy.Value = -ang
end
end
