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

Using the new TweenService with models?

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

local TweenService = game:GetService('TweenService')
local a = workspace.A
local i = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
wait(1)
local ta = TweenService:Create(a, i, { CFrame = a.CFrame * CFrame.new(0, 5, 0) })
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?

1 comment

0

You could either do Model:SetPrimaryPartCFrame(part.CFrame) on the client on a function binded to renderstep before render or use tweenservice on a for loop

1 answer

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

Properties = {
Position = Vector3.new(10,10,5)
Size = Vector3.new(5,5,5)
Transparency = 1
}

Etc.

and you have to make a Tween Info to make one you have to:

local tweenInfo = TweenInfo.new(
	2,								-- Length of an interpolation
	Enum.EasingStyle.Elastic,		-- Easing Style of the interpolation
	Enum.EasingDirection.Out,		-- Easing Direction of the interpolation
	5,								-- Number of times the sequence will be repeated
	true,							-- Should the sequence play in reverse as well?
	2								-- Delay between each interpolation (including reverse)
-- Create the "Tween" object that represents the playback of this interpolation
local tween = TweenService:Create(THEPART,tweenInfo,Properties)
 
-- Play the interpolation:
tween:Play()

and by that you can easily figure out how to move your model using primarypart.

2 comments

0

Hope this helps :)

0

Hi! Thanks for your comment - This is actually my bad here... this whole time I didn't actually specify the exact problem. Sorry! The single primary part works flawlessly. The fact is that only the primary part will move within a model, not the rest of the parts within it. Consult this: https://gyazo.com/d303bae412fc19177a36c7b36d9b60be On the right, a model contains two bricks but only one moves.

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