oh! my apologies! I forgot to add the most important thing!
here is my script
--local plane = game.ReplicatedStorage.Plane
local TweenModelService = require(game.ReplicatedStorage.TweenModelService)
local planeModel = game.ServerStorage.PlanesFolder["Boeing 737-800"]
local plane = planeModel.Light678
local planParts = workspace.PlaneSpawn
local tweenService = game:GetService("TweenService")
local tweenInfo1 = TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local tweenInfo2 = TweenInfo.new(10, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0, false, 0)
local tweenInfo3 = TweenInfo.new(10, Enum.EasingStyle.Exponential, Enum.EasingDirection.In, 0, false, 0)
local orientationTweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
function lvToOrientation(lv)
return Vector3.new(
lv.X * lv.Z,
lv.X * lv.Y,
lv.Y * lv.Z
)
end
function calculateOrientation(cframe)
local x, y, z = cframe:ToOrientation()
return Vector3.new(math.deg(x), math.deg(y), math.deg(z))
end
task.wait(10)
planeModel.Parent = workspace
--planeModel:PivotTo(planParts.Start.CFrame)
plane.CFrame = planParts.Start.CFrame
task.wait(10)
local tween1 = tweenService:Create(plane, tweenInfo3, {Position = planParts.Part0.Position})
tween1:Play()
tween1.Completed:Connect(function()
local currentLocation = plane.Position --> current location
local nextLocation = planParts.Part1.Position --> next location
local cf = CFrame.lookAt(currentLocation, nextLocation)
local cframe1 = (planParts.Part1.CFrame*CFrame.lookAt(currentLocation, nextLocation))-- * CFrame.lookAt(plane.Position, planParts.Part1.Position)
print(cframe1.Position)
local orientation = calculateOrientation(cf)
local tween2 = tweenService:Create(plane, tweenInfo1, {["Position"] = planParts.Part1.Position, ["Orientation"] = orientation})
local orientationTween = tweenService:Create(plane, orientationTweenInfo, {["Orientation"] = orientation})
tween2:Play()
orientationTween:Play()
print("tween started")
--local tween2 = tweenService:Create(plane, tweenInfo1, {Position = planParts.Part1.Position})
--tween2:Play()
tween2.Completed:Connect(function()
currentLocation = plane.Position --> current location
nextLocation = planParts.Part2.Position --> next location
cf = CFrame.lookAt(currentLocation, nextLocation)
local cframe2 = (planParts.Part2.CFrame*CFrame.lookAt(currentLocation, nextLocation))-- * CFrame.lookAt(plane.Position, planParts.Part1.Position)
print(cframe2.Position)
--local cframe2 = CFrame.new(planParts.Part2.Position, planParts.Part2.Position) --* CFrame.lookAt(plane.Position, planParts.Part2.Position)
orientation = calculateOrientation(cf)
print(orientation)
local tween3 = tweenService:Create(plane, tweenInfo1, {["Position"] = planParts.Part2.Position,})
orientationTween = tweenService:Create(plane, orientationTweenInfo, {["Orientation"] = orientation})
tween3:Play()
orientationTween:Play()
--local tween3 = tweenService:Create(plane, tweenInfo1, {Position = planParts.Part2.Position})
--tween3:Play()
tween3.Completed:Connect(function()
--task.wait(5)
currentLocation = plane.Position --> current location
nextLocation = planParts.Part3.Position --> next location
cf = CFrame.lookAt(currentLocation, nextLocation)
local cframe3 = (planParts.Part3.CFrame*CFrame.lookAt(currentLocation, nextLocation))-- * CFrame.lookAt(plane.Position, planParts.Part1.Position)
--local cframe3 = CFrame.new(planParts.Part3.Position, planParts.Part3.Position)--) * CFrame.lookAt(plane.Position, planParts.Part3.Position)
orientation = calculateOrientation(cf)
print(orientation)
local tween4 = tweenService:Create(plane, tweenInfo1, {["Position"] = planParts.Part3.Position,})
orientationTween = tweenService:Create(plane, orientationTweenInfo, {["Orientation"] = orientation})
tween4:Play()
orientationTween:Play()
--local tween4 = tweenService:Create(plane, tweenInfo1, {Position = planParts.Part3.Position})
--tween4:Play()
tween4.Completed:Connect(function()
--task.wait(5)
currentLocation = plane.Position --> current location
nextLocation = planParts.End.Position --> next location
cf = CFrame.lookAt(currentLocation, nextLocation)
local cframe4 = (planParts.End.CFrame*CFrame.lookAt(currentLocation, nextLocation))-- * CFrame.lookAt(plane.Position, planParts.Part1.Position)
--local cframe4 = CFrame.new(planParts.End.Position, planParts.End.Position)-- * CFrame.lookAt(plane.Position, planParts.End.Position)
orientation = calculateOrientation(cf)
print(orientation)
local tween5 = tweenService:Create(plane, tweenInfo2, {["Position"] = planParts.End.Position})
plane.Orientation = Vector3.new(math.deg(0), plane.Orientation.Y, plane.Orientation.Z)
--orientationTween = tweenService:Create(plane, orientationTweenInfo, {["Orientation"] = orientation})
tween5:Play()
--orientationTween:Play()
--local tween5 = tweenService:Create(plane, tweenInfo2, {Position = planParts.End.Position})
--tween5:Play()
tween5.Completed:Connect(function()
print("flight complete")
end)
end)
end)
end)
end)