Help with Model Tweening

Hey Everyone! So, I have a problem with Model Tweening. I have Screen Model that tweens when I’m clicking on the part using ClickDetector. And when I’m clicking on it, It’s only tweens PrimaryPart, not Model.

What solutions have you tried so far? I’ve already tried to Weld it using the RigEdit plugin. But it’s tweening only one part.

Here are the lines of code that I’m using:

local model = script.Parent
local ts = game:GetService("TweenService")
local posEnd = model.PrimaryPart.Position + Vector3.new(0, 9, 0)
local move = ts:Create(model.PrimaryPart, TweenInfo.new(Enum.EasingStyle.Quad,
          Enum.EasingDirection.Out), {Position = posEnd})
move:Play()

If someone helps, it would be really appreciated! Thanks.

Tweening a part’s position won’t take into account the assembly (welds). If you want to use welds, tween the CFrame instead. If you want to not use welds, create a proxy CFrameValue and use that to pivot the model.

2 Likes

A CFrameValue is not necessary for this

local heartbeat = game:GetService("RunService").Heartbeat

local function lerpModelToCFrame(model: Model, tweenTime: number, destination: CFrame)
	local startPivot = model:GetPivot()

	local totalDelta = 0

	local connection
	connection = heartbeat:Connect(function(delta)
		totalDelta += delta
		if totalDelta > tweenTime then
			totalDelta = tweenTime
			model:PivotTo(destination)
			connection:Disconnect()
			return
		end

		model:PivotTo(startPivot:Lerp(destination, totalDelta/tweenTime))
	end)
end
1 Like

Thanks for helping! Now it’s working.

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