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()
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