I've been playing around with TweenService for some time - and it works really well with single parts.
This is a basic example of a part that will move upwards linearly
1 | local TweenService = game:GetService( 'TweenService' ) |
2 | local a = workspace.A |
3 | local i = TweenInfo.new( 2 , Enum.EasingStyle.Linear, Enum.EasingDirection.Out) |
4 | wait( 1 ) |
5 | local ta = TweenService:Create(a, i, { CFrame = a.CFrame * CFrame.new( 0 , 5 , 0 ) } ) |
6 | ta:Play() |
However, I want to use this with models. The only way that I'm aware of is doing
Model:SetPrimaryPartCFrame(**Desired CFrame**)
and I've tried a few things but I have absolutely no idea how to use tweening with models, and it doesn't seem as simple as lerping with models which I have done before.
Is it possible? If so, how can it be done?
you have to add a Dictionary to make it work. Dictionary is like a table, but instead it's a list of properties.
e.g
1 | Properties = { |
2 | Position = Vector 3. new( 10 , 10 , 5 ) |
3 | Size = Vector 3. new( 5 , 5 , 5 ) |
4 | Transparency = 1 |
5 | } |
Etc.
and you have to make a Tween Info to make one you have to:
1 | local tweenInfo = TweenInfo.new( |
2 | 2 , -- Length of an interpolation |
3 | Enum.EasingStyle.Elastic, -- Easing Style of the interpolation |
4 | Enum.EasingDirection.Out, -- Easing Direction of the interpolation |
5 | 5 , -- Number of times the sequence will be repeated |
6 | true , -- Should the sequence play in reverse as well? |
7 | 2 -- Delay between each interpolation (including reverse) |
1 | -- Create the "Tween" object that represents the playback of this interpolation |
2 | local tween = TweenService:Create(THEPART,tweenInfo,Properties) |
3 |
4 | -- Play the interpolation: |
5 | tween:Play() |
and by that you can easily figure out how to move your model using primarypart.