I’m working on a Tweening script for some landing gear for some planes I am working on. I am looking to have the script rotate the plane’s landing gear by 90 degrees, and then move it by studs in the Y direction.
Here’s my script:
local angle = CFrame.Angles(0,math.rad(45),0)
local goal = {}
local tweenInfo = TweenInfo.new(5)
local TweenService = game:GetService("TweenService")
goal.Orientation = Vector3.new(0,0,-90)
goal.CFrame = CFrame.new(script.Parent.Position) + Vector3.new(0,-3,0)
local tween = TweenService:Create(script.Parent, tweenInfo, goal)
tween:Play()
I did that, but the issue became this: https://gyazo.com/db7b296efa0473aa0f61d2870791c487
The positioning of the landing gear got wonky as the plane moved, which is going to happen as players fly these things.
local goal = {Orientation = Vector3.new(0,0,-90), Position = script.Parent.Position + Vector3.new(0,-3,0)}
-- to add a position locally (with CFrames) do: Vector3.new(script.Parent.CFrame * CFrame.new(0,-3,0))
2 things, you can’t add a vector3 to a CFrame, and try to to not manipulate a parts position/orientation and its CFrame at the same time as CFrame describes both position and rotation already (i dont know what happened if you did but you could imagine the confusion)
the easiest fix for this is to animate the landing gear with moon animator(if you have it) or tween the C0/C1 property of a motor6d/WeldConstraint that connects the landing gear to the hinge on the airplane