Tweening the position of the primary part doesn't tween the whole model even when welded

as the title says

I’m trying to tween the position of the model while having all of it’s children in the right place. However, when I tween the primaryPart (which is welded to all children) only the primary part moves and the other parts just float without moving.

Now I know the solution is to tween the CFrame instead but I’m trying to keep the orientation of the model the same and CFrame doesn’t help with that

local PrimaryPart = script.Parent.PrimaryPart
local TweenService = game:GetService("TweenService")
local Tweeninfo = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.In)
local Properties = {Position = workspace.TestPart.Position}


task.wait(3)
print("Moving")

PrimaryPart.CFrame = CFrame.lookAt(PrimaryPart.Position,workspace.TestPart.Position)
task.wait(2)
TweenService:Create(PrimaryPart,Tweeninfo,Properties):Play()

Any help would be great

Use Model:TranslateBy(position: Vector3) if you wish to move a model while preserving orientation.
You should really be using PVInstance:PivotTo(targetCFrame: CFrame) though.

To tween using these methods though you would probably want a script that looks like this

local TweenService = game:GetService("TweenService")

local function TweenModelCFrame(Model: Model, Info: TweenInfo, TargetCFrame: CFrame)
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Changed:Connect(function(NewCFrame)
		Model:PivotTo(NewCFrame)
	end)
	
	local Tween = TweenService:Create(CFrameValue, Info, {Value = TargetCFrame})
	Tween:Play()
	
	Tween.Completed:Connect(function()
		CFrameValue:Destroy()
		Tween:Destroy()
	end)
end
1 Like

Just make a new CFrame with only the position of the Part set.

local PrimaryPart = script.Parent.PrimaryPart
local TweenService = game:GetService("TweenService")
local Tweeninfo = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.In)
local TestC = workspace.TestPart.CFrame
local NewC = CFrame.new(TestC.X, TestC.Y, TestC.Z)  * PrimaryPart.CFrame.Rotation
local Properties = {CFrame = NewC}


task.wait(3)
print("Moving")

PrimaryPart.CFrame = CFrame.lookAt(PrimaryPart.Position,workspace.TestPart.Position)
task.wait(2)
TweenService:Create(PrimaryPart,Tweeninfo,Properties):Play()

1 Like