Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I tween a model?

I have a very large model that I need to tween all at once. I've used model:SetPrimaryPartCFrame inside of a for loop, but it's wayyy too jittery. Is there a way to utilize the tween service to make the movement of it smoother? I've tried some methods such as

local tweenService = game:GetService("TweenService")
local info = TweenInfo.new()

local function tweenModel(model, CF)
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()

	CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)
	
	local tween = tweenService:Create(CFrameValue, info, {Value = CF})
	tween:Play()
	
	tween.Completed:Connect(function()
		CFrameValue:Destroy()
	end)
end

but it always returns and error with the CFrame value when I do tweenService:Create().

What is the most efficient way to accomplish this?

1 answer

The most efficient way that I personally use is that:

  1. I unanchor all parts

  2. I anchor only one part (which I am going to tween and use as my "PrimaryPart" for that model)

  3. I use Motor6Ds to weld all the parts together to the "PrimaryPart".

  4. I then proceed to tween my anchored "PrimaryPart", and the model will follow it.

Note: To make the process easier and faster I use this weld Plugin to make my Motor6D's, it is very helpful.

This is the smoothest way to tween models to my knowledge after experimenting. I hope this helps, please let me know if you have further questions!

6 comments

0

Agreed

0

Paired with RenderStepped:wait(), it would run incredibly smooth, though not necessary.

0

I would not recommend using the tweening with any kind of loop

0

I would try that, the thing is there are so many objects (parts and unions) inside of this model that I don't want to mess it up.

0

Oh sorry, I thought he was moving it based on CFrame alone. You can tween parts now?

0

It wouldn't mess it up, what I usually do is just make an invisible part with collision off covering the whole model and make that my primary anchored part and weld all the parts to it

This discussion is preserved as it was. New answers, comments, and votes are closed.