Rotate model with tween, how?

The signal that GetPropertyChangedSignal returns only fires each frame.
It would be good that Roblox give us a way to directly tween models.

1 Like

You’re right, but I suppose that’s the only option for now

2 Likes

thx, u mean like a primary part within the model and just tween the primary part with everything else welded together?

If so, then ik what ure talking about!

We should contact them about that

That will not work. Tweens do not take into account any physics constraints while tweening.

hm weird, ive seen multiple other forums suggest something like that

This is what i was thinking:

  • Have a primary Part
  • Weld all parts together then model them
  • Tween just the primary part to a certain angle degrees rotation

Then the entire model would have rotate it slightly then back with a simple tween

I’ve just tested it and it doesn’t work. It just moves the primary part but the welded part does not follow it.

hmm weird, maybe if you PivotTo(–CFRAME–) with a lerp ?

I’ve made a simple example following that approach:

local asmRoot = workspace.Model:FindFirstChildWhichIsA("BasePart").AssemblyRootPart
local start = asmRoot.CFrame
local init = os.clock()
local time = 5
local endTime = init + time
local goal = CFrame.new(5, 5, 5) * CFrame.Angles(math.deg(- 90), 0, 0)

local conn
conn = game:GetService("RunService").Heartbeat:Connect(function()
	if os.clock() > endTime then
		asmRoot:PivotTo(goal)
		conn:Disconnect()
	else
		asmRoot:PivotTo(start:Lerp(goal, (os.clock() - init) / time))
	end
end)

ill see what i can do with MY knowledge, thakns for the tips tho

local TweenService = game:GetService("TweenService")
local movingModel = script.Parent
local goalPart = script.Parent.Parent.Point1

do
	local cfv = Instance.new("CFrameValue")
	cfv.Value = movingModel:GetPivot()
	cfv.Changed:Connect(function(new_cf)
		movingModel:PivotTo(new_cf)
	end)
	local tween = TweenService:Create(
		cfv,
		TweenInfo.new(
			4, -- time
			Enum.EasingStyle.Cubic,
			Enum.EasingDirection.InOut,
			-1, -- repeat (-1 = inf)
			true, -- reverse?
			0 -- delay
		),
		{
			Value = goalPart.CFrame
		}
	)
	tween.Completed:Once(function()
		cfv:Destroy()
	end)
	tween:Play()
end

ill try it out, ill let u know if it works and mark it as a the solution! :slight_smile:

got an error, the same one from always

Here is how to rotate a model with a tween:

  • Anchor a main part that will be used as the center of movement
  • Unanchor the other parts
  • Weld the other parts to the main part
  • Tween the main part

If you’re doing the tweening on the server, you can make the tween smooth on the clients using the community module TweenService V2:

welp, ive tried that already, what u suggested, and it didnt work, idk about the tweenv2 tho

If you change the “goalPart.CFrame” to “goalPart:GetPivot()” it should work

local TweenService = game:GetService("TweenService")
local movingModel = script.Parent
local goalPart = script.Parent.Parent.Point1

do
	local cfv = Instance.new("CFrameValue")
	cfv.Value = movingModel:GetPivot()
	cfv.Changed:Connect(function(new_cf)
		movingModel:PivotTo(new_cf)
	end)
	local tween = TweenService:Create(
		cfv,
		TweenInfo.new(
			4, -- time
			Enum.EasingStyle.Cubic,
			Enum.EasingDirection.InOut,
			-1, -- repeat (-1 = inf)
			true, -- reverse?
			0 -- delay
		),
		{
			Value = goalPart:GetPivot()
		}
	)
	tween.Completed:Once(function()
		cfv:Destroy()
	end)
	tween:Play()
end

If you set it up properly it will work. If it doesn’t move properly, make sure none of the other parts are anchored. If it falls apart, make sure all the parts are welded.

What i have done:

-Weld all parts together
-Unanchor all aprts except primary part

This hasnt solved the issue tho

i was wondering this, like shouldnt i have done something like with pivot to get the cframe of the model?

But ill try that later or tomorrow

YOOOOOO FINALLY IT WORKED IT FINALLY WORKED!

After DAYS OF RESEARCH AND ASKING FOR HELP, IT FINALLY WORKED!!!

THANK YOU!

I knew it had to do something with the getpivot of the other model basically indicating its “Cframe”, gosh i just didnt know how to do it

Thank you @hkep and @LwgoVlr for fixing the tiny mistake in the code! You guys are the best!