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

Help with using Tween Service on Models?

Asked by 5 years ago

I've recently tried to tween a model by its PrimaryPart but It only tweens the PrimaryPart and not the entire model. I've even tried welding every part in my model to it's PrimaryPart and it still doesn't give me the result I'm looking for.

The code I use to tween is below. Any suggestions or changes I should make?

local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
    5,
    Enum.EasingStyle.Elastic,
    Enum.EasingDirection.In,
    0,
    false,
    0
)

local Pos = {}
    Pos.Position = Vector3.new(Character.UpperTorso.CFrame*CFrame.new(0, -1.7, -4));

local tween = TweenService:Create(MyModel.PrimaryPart,Info,Pos)
tween:Play()

1 answer

Log in to vote
0
Answered by 5 years ago

You are not able to tween a model as it has no position value. The position is based upon the primary part which you need to use the function SetPrimaryPartCFrame.

You can however use the lerp function of a CFrame but this will not have the same easing style.

Example:-

local endCF = Character.UpperTorso.CFrame*CFrame.new(0, -1.7, -4)
local startCF = MyModel:GetPrimaryPartCFrame()

for i=0, 1, 0.1 do
    MyModel:SetPrimaryPartCFrame(startCF:lerp(endCF, i))
    wait()
end

I hope this helps.

0
Thanks! This worked perfectly. captain97marvel 2 — 5y
0
Make sure you accept it as an answer if it worked for you... It helps the poster's reputation and makes sure the community knows they can answer questions helpfully. Hexcede 52 — 5y
Ad

Answer this question