# Move and Rotate Models using Tween at the Same Time

[HELP] Move and Rotate Models using Tween at the Same Time

I am making a ship sinking game and I use TweenService to move and rotate it.

Problem: I can’t find a way to change the two properties (Movement and Rotation) using CFrame, the only thing I can do is change them individually, but when putting them together only one runs.

Goals: Achieve moving and rotating a model at the same time using the Tween Service

I need someone to help me.
As soon as possible.
Thx

Here’s a guide for tweening models:

If you want to tween both position and rotation, then you’re going to want to tween the `CFrame` property. You can set the goal to something like

``````local pos = -- intended position which is a Vector3
local xRot, yRot, zRot = -- The rotations on each axis
local cfGoal = CFrame.new(pos) * CFrame.Angles(xRot, yRot, zRot) -- The goal to tween the CFrame to
``````

### Further Explanation

A CFrame holds the rotation and position, so if you want to rotate them both at the same time, you might as well tween the CFrame.

In the above variable `cfGoal`, I construct a CFrame which is at the specified position `pos` and with the specified orientation. Orientation is a Vector3 with the angles of rotation on each axis and can put those angles of rotation into `CFrame.Angles()` and multiply it with a CFrame to rotate it. Keep in mind that Orientation has the angles in degrees whereas `CFrame.Angles()` has the angles in radians. `CFrame.new()` makes a CFrame at the specified position but its orientation is just the default orientation. You’ll want to rotate it to have it rotated. If you’d like the rotation to be relative to the original, then you can reference the original CFrame:

``````local part = -- The part you're tweening
local pos = -- intended position which is a Vector3
local xRot, yRot, zRot = -- The rotations on each axis
local cfGoal = CFrame.new(pos) * CFrame.Angles(part.CFrame:ToEulerAnglesYXZ()) * CFrame.Angles(xRot, yRot, zRot) -- The goal to tween the CFrame to
``````

This way, it applies the original rotation, first, and the new rotation will be applied relative to the original.

### Why CFrame:ToEulerAnglesYXZ()?

This is so the Y-axis rotation is applied first. Using `ToEulerAnglesXYZ()`, there’s a limited range for the Y-axis rotation that can make the rotations inaccurate. `ToEulerAnglesYXZ()` makes sure you have the correct Y-axis rotation. Both of them return the angles of the rotations of each axis in radians.

6 Likes

Just tween the CFrame it auto alines including the rotation.

1 Like