How to tween only a cframes rotation?

Pretty much I want to just tween a parts cframe rotation. The part is constantly moving so obviously if I tween it using cframe.lookat() its gonna try to tween itself backwards and it looks weird.

How should I go about only tweening the rotation and nothing else? That way it doesnt look jittery while its moving.

You can tween the orientation to change just the rotation of the part.

--//Services
local TweenService = game:GetService("TweenService")

--//Variables
local Part = workspace.Part

--//Functions
local RotationTween = TweenService:Create(Part, TweenInfo.new(1, Enum.EasingStyle.Linear), {
	Orientation = Vector3.xAxis * 90
})

RotationTween:Play()
1 Like

How could I turn a CFrame.lookat into an orientation? or alternatively a direction into an orientation

Wait, before I post how, why do you need to do this when you can just do CFrame = CFrame.lookAt(part1, part2)?

1 Like

like I said before the part being tweened is constantly moving so it tweens it back

Could you paste your code to tween it?

It shouldn’t tween it back since new tweens override the previous ones.

1 Like

local tween = tweenservice:Create(part,TweenInfo.new(.1),{CFrame = CFrame.lookAt(part.Position,bpPos)})

Unanchored parts already moving should not be tweened because the Roblox physics engine will calculate positions that are in conflict with the tween causing the jitter you see. Instead, use a Body Mover. Body Movers are managed by the Roblox physics engine so they will produce smooth motion. It sounds like you need to parent an AngularVelocity body mover to your object to get it to rotate. AngularVelocity will apply the necessary force to maintain a constant angular velocity that you specify.

1 Like

Is the velocity value an orientation? How would I get the proper angle to set the velocity to?

also it turns out an angularvelocity is going to constantly be spinning the part in that velocity. I’m trying to maintain an orientation while moving.

Use AlignOrientation to maintain a constant orientation. This is the old BodyGyro which I think is a better name. Set OrientationAlignmentMode to Enum.OrientationAlignmentMode.OneAttachment to have it act like a gyro and point the part in the orientation of a CFrame. If you need it to track a fixed position, like say you have a moving part you want always pointing at a fixed spot, you will probably need to keep updating the orientation CFrame in the body mover. There may be other combinations of movers and constraints you can use to pull of various other movement mechanics. Check out Mover Constraints | Roblox Creator Documentation

2 Likes

how to make the CFrame of this local?