Using two tweens for a Model

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to be able to make a model tween forwards and rotate at the same time

  1. What is the issue? Include screenshots / videos if possible!

I am using the primary part to tween the mdoels CFrame wich works when the two tweens are seperate. But when applied together they conflict. Using Orientation and Position seperate works for the primary part, but it does not take the rest of the model with it.

  1. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    Using .Postion and .Orientation seperate but only works for primary part. Welding all parts to the model did not work either.

Is there any way to do this right? Thanks!

You can use the Model’s Pivot methods (Model:GetPivot() and Model:PivotTo(CFrame)

In combo with RunService you can use :Lerp() and PivotTo()

local start = Model:GetPivot()
local target = CFrame.new(0, 15, 0) * CFrame.Angles(0, 0, math.rad(15))

local tweenTime = 5
local eTime = 0
local conn
conn = game:GetService("RunService").Heartbeat:Connect(function(dt)
    eTime += dt
    local alpha = math.min(eTime, tweenTime) / tweenTime
    local current = start:Lerp(target, alpha)
    Model:PivotTo(current)

    if alpha == 1 then
        conn:Disconnect()
        conn = nil
    end
end)
2 Likes

If you want a custom easing style since the provided code I gave is linear, you can use

local TweenService = game:GetService("TweenService")

local newAlpha = TweenService:GetValue(alpha: number, easingStyle: Enum.EasingStyle, easingDirection: Enum.EasingDirection)
local current = start:Lerp(target, newAlpha)
Model:PivotTo(current)

Thanks! I will have a look at this. I thaught about trying this but it seemed like ti might be a bit janky.

No, it shouldn’t be janky.

I’ve used Pivot and it’s much easier and faster to do! I also like how you don’t need to set the PrimaryPart.

The only thing that is harder is that it takes up more lines of code because you aren’t using TweenService

Thanks! It works perfectly! :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.