Rotate a part, based on anothers parts Position

Hello Developers;

I am currently working on a tower defense game. I need to make a system where when a part moves, another part will rotate based on it. (May sound confusing, so here is a video on what I am talking about). What I am trying to accomplish is an automatic version of what is shown in the video, shown above.

I know it would involve CFrame and Velocity, but my current system just does this

So you want it to aim at the other Part?
Try CFrame.lookAt here: CFrame | Roblox Creator Documentation

1 Like

This is my system, and it is already using CFrame, except the part is orbiting around the other part instead of aiming

   wait(5)
   while true do
wait(0.1)
local Part1 = game.Workspace.GoodGuy
local Part2 = game.Workspace.BadGuy

local rotation = Part1.CFrame:Inverse() * Part2.CFrame

Part1.CFrame = Part1.CFrame * CFrame.Angles(0,math.rad(1), 0)
Part2.CFrame = Part1.CFrame * rotation

end

Try reading the section about CFrame.lookAt.

1 Like

Thank you, it is working properlly now → watch