Part look at the direction of a part

How do I make a Part look at the direction of a part. I need a better alternative.

local partA = ... -- part we want to move
local partB = ... -- the target part
partA.CFrame = CFrame.new(partA.Position, partB.Position)

To explain, a CFrame carries two vectors:

CFrame.new ( Positional Vector, Directional Vector )

Positional vector is where the pivotal component gets placed in world space.

Directional vector is where the part’s front face is look towards.

Use CFrame.lookAt(vector3 position,vector3 rotation)

part1.CFrame = CFrame.lookAt(part1.CFrame.Position,part2.CFrame.Position)
2 Likes