How to tween a model

Hey im trying to tween a model.

The official way to do this is to create a root part, weld everything to it, then tween the root.

The main issue is though for some reason my parts arent following the root around.

heres my code:

if clone:IsA("Model") then
			rootPart = Instance.new("Part")
			rootPart.Size = Vector3.new(0.1, 0.1, 0.1)
			rootPart.Name = "root"
			rootPart.Anchored = true
			rootPart.CanCollide = false               -- avoid collision with world while tweening
			rootPart.Transparency = 1
			rootPart.CFrame = clone:GetPivot()
			rootPart.Parent = clone

			pcall(function() clone.PrimaryPart = rootPart end)

			for _, v in ipairs(clone:GetDescendants()) do
				if v:IsA("BasePart") and v ~= rootPart then
					local weldC = Instance.new("WeldConstraint")
					weldC.Part0 = v
					weldC.Part1 = rootPart
					weldC.Parent = v
				end
			end
		
		else
			rootPart = clone
		end


			local tween = TweenService:Create(rootPart, TweenInfo.new(t, Enum.EasingStyle.Linear), {Position = endPos})
			tween:Play()
			tween.Completed:Wait()

As you can see I weld everything to the root and then tween the root but for some reason the root moves but the parts attached dont.

Im not sure because it says its active in the constraint

Yet refuses to follow it

I verified and its

1 Like

Hey, i’m pretty sure that if anything else of the model that is not the root part is anchored, it won’t tween.
Pretty tired so unsure but, if it doesn’t work let me know.

To add onto this, you might have too much weldconstraints.
One weldconstraint per child (non-root) is enough.

If i dont anchor the root the model fases throuhh the world thi

There are two ways to set this up:
Option A:
Anchor only the root part, and weld all of the unanchored parts to the root and then tween the root
Option B:
Use RunService and lerp the CFrame of the model (Use :PivotTo() to move the model)

Or ofcourse option C

  1. Create CFrame value cframeProxy (recommend doing so programatically)
  2. set to initial value to be tweened (e.g. cframeProxy.Value = Model.GetPiviot())
  3. Tween CFrame value
  4. On value changed event connect function, use PiviotTo(cframeProxy.Value) on original model
  5. Clean up after tween down

This is the approach I did but the other parts dont follow the root unless the root is unanchpred as well for some reason

I meant that the only part of the model needed to be anchored is the root. Nothing else.

If you can’t tween it, try lerping

You need to tween the CFrame of the root part if you want the welded parts to follow, not the position.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.