Rotating a Part Towards Another Part
Rotating a Part Towards Another Part
Problem
You want to rotate a part toward another part.
Solution
Use the second CFrame argument to rotate in that direction.
local part = Instance.new('Part') part.Parent = Workspace part.Anchored = true part.CFrame = CFrame.new(Vector3.new(0, 0, 0), Workspace.pointAtPart.Position)
Discussion
We’re basically setting part.CFrame
to a new CFrame which is at the position of (0, 0, 0)
, and is rotated at the part pointAtPart
. We use pointAtPart.Position
because we want to point at a Vector3
value which is returned by the Position
property or CFrame.p
.