Best way to tween models?

What is the easiest way to move models through tween? As it only works in 1 part but I never tried using models.

1 Like

You can tween multiple parts at the same time. Are you moving the whole model statically, or do parts move on their own relative and in addition to the core of the model?

1 Like

place CFrame value somewhere and tween value in it. After add an event when value changes and set primary part cframe of model.
like this

local value = Instance.new('CFrameValue',model)
value.Value = model:GetPrimaryPartCFrame()
local tween = tweenService:Create(value,..,..)
tween:Play()
value.GetPropertyChangedSignal('Value'):Connect(function()
    model:SetPrimaryPartCFrame(value.Value)
end)
1 Like

All of it moves at the same time

Not quite good in using cframe

You can move models only using CFrame.

1 Like

Well, I will try seeing other ways anyways thanks for the info!

1 Like

Just make sure to do this on the client or it won’t be smooth. Plus, the client should be the one to handle all animations anyway.

1 Like
local targetCF = workspace.target.CFrame

script.Parent:PivotTo(script.Parent:GetPivot():Lerp(targetCF, .5)) -- half way there!

Probably not the best approach, but you can hook this to a for i loop; or you can make a NumberValue and tween the value from 0 to 1 and while its tweening, use the NumberValue for the alpha

2 Likes

That was quite helpful, will make sure to do that thx

1 Like

I find lerping a bit laggy, but will try using it thank u

1 Like

Would personally never recommend this if it’s for moving a model at once, even if it’s on the client :cold_sweat:

Unless I read the reply wrong which could be the case :man_shrugging:

1 Like

Well I used to do that, Put a script inside each part to move together, definitely lagging so bad

1 Like

Using different scripts basically puts it on different threads (not an actual different thread, but I won’t get into the difference right now). This means you’re having multiple things run essentially simultaneously. Now tweens sort of do that already, but you can instead run them in steps. This will greatly reduce the lag over running on multiple scripts.

With that said, it can still cause lag with enough tweens going on.

This is what I’ve done with clouds in the past using tweens:

2 Likes

This looks fabulous! so what your saying is I can just tween them all in 1 script without putting any wait functions to make them all run at same time?

1 Like

Yes, tweens won’t yield, so you can run them at the same time. Just be aware that too many tweens on one actual thread can cause lag at a certain point. If running on the client, like it should be, that limit will likely depend on the client.

You can actually use some fancy code to optimize movement and even have them move at different rates or skip to the correct position when not in view of the camera, or make it dynamic to the client’s performance, etc.

Or if you have a lot of things going on and you don’t feel like writing any fancy code, you could use multi-threading (or more accurately known as desynchronized with Parallel Lua). But I don’t think that’s out of beta yet?

3 Likes

I will most likely put it in a client’s side and yes as you said it will depend on the laptops/pc performance and the other thing desynchronized? never quite heard of it so idk how to use it, but thank you for your help that was very appreciative

It’s not out of beta yet, so I don’t think it’s listed in the public developer wiki thing at the moment. Plus it doesn’t work in live servers anyway. But it uses task.desynchronize() with the Parallel Lua Beta.

1 Like

https://www.roblox.com/library/8175196986/ModelTween
FYI, I got a module which does that, the only issue is that it can tween 1 property at time

2 Likes

Will make sure to read through it, thank you!

1 Like