Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I tween a model?

Asked by 4 years ago

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

Log in to vote
2
Answered by
Nanomatics 1160 Moderation Voter
4 years ago
Edited 4 years ago

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!

0
Agreed Infocus 144 — 4y
0
Paired with RenderStepped:wait(), it would run incredibly smooth, though not necessary. Infocus 144 — 4y
0
I would not recommend using the tweening with any kind of loop Nanomatics 1160 — 4y
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. Skychiild 4 — 4y
View all comments (2 more)
0
Oh sorry, I thought he was moving it based on CFrame alone. You can tween parts now? Infocus 144 — 4y
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 Nanomatics 1160 — 4y
Ad

Answer this question