How to make a part face the direction of another part

How do I make a part face the direction of another part. I tried several things like getting the magnitude and trying to use CFrame.Angles but I simply cant get it to work please help.

Use CFrame.lookVector; it can be used any time a CFrame is present (for instance, checking the lookVector of a part’s CFrame to get where it’s facing)
CFrame docs

Yeah I’m new to lookvector idk how to do that

If I’m correct I believe you can just do

local part1 = workspace.Part1
local part2 = workspace.Part2
local pos = CFrame.new(part1.Position, part2.Position)
part1.CFrame = pos

Which means you didn’t actually need lookvector in the end and I was overthinking it.

Hmmm that doesnt seem to work here is my script

local part1 = script.Parent

local part2 = workspace.Parent

local pos = CFrame.new(part1.Position, part2.Position)

while true do

wait()

part1.CFrame = pos

end

Position is not a valid member of DataModel

I didn’t know you wanted to constantly make it look towards the part. If you want to replicate this locally, use RunService.RenderStepped as it will be smoother.

1 Like

Yes but how do i make it face the other part I have tried so many things

For the second part, you used workspace.Parent, which isn’t a part, but it’s actually the instance game.

Oops that was an autosuggestion mistake lol.

1 Like

Cframe.new(position, lookat) has been deprecated.

Consider using CFrame.lookat(position, lookat)

1 Like