Model Tween Won't Work

Hey there! I have a big problem. I am trying to get this plane to tween, but it just won’t work! I have the model welded to the primary part, but the only thing that moves is the primary part.

Here is a video of the primary part moving but others not
robloxapp-20240124-0906309.wmv (349.2 KB)

2 Likes

Could you show us your script?

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)

If you have problems with tweening just the model the you could use this to tween models:

function TweenModel(obj, Cframe, info)
	local value = Instance.new("CFrameValue")
	value.Value = obj:GetPivot()

	local function update()
		obj:PivotTo(value.Value)
	end
	value:GetPropertyChangedSignal("Value"):Connect(update)
	
	local Tween = TweenService:Create(value, info, {Value = Cframe})
	Tween:Play()
	Tween.Completed:Wait()
	value:Destroy()
end

TweenModel(workspace.Model, CFrame.new(0, 5, 0), TweenInfo.new(1))

I’ve thought about CFrame before, but that won’t allow me to tween the orientation (I want the orientation to move at a seperate speed than the position, so that’s why I do it seperately)

U can do that with the function I’m pretty sure.

It sounds like you have all the Parts Anchored.
Only the part you are tweening (with all the others welded to it) should be anchored.

The only part that is anchored is the PrimaryPart