Making a model constantly look the direction of a part

I am trying to make a script that will constantly update a model (rigged with welds + a primarypart) to constantly look towards another part.


This is what I have gotten so far, and I want the camera to rotate towards the red part.

I have tried numerous other posts answers but couldn’t seem to get it working myself.


Above is an image of my hitbox, in case it helps.

1 Like

I’m pretty sure CFrame.lookAt() will help
Which you can find here

3 Likes

Do you have any examples of using this? I am still a bit confused on CFrames as a whole.

example

RunService.Heartbeat:Connect(function()
   local cf = Model:GetPrimaryPartCFrame()
   -- this gets the model's CFrame if it has a primary part (required)
   Model:SetPrimaryPartCFrame(CFrame.lookAt(cf.Position, Target.Position))
   -- this sets the cframe to look at the part
end)
3 Likes

A CFrame is the Position and Orientation of a part.

2 Likes

Hi! I understand it a bit more now, and this worked! Thank you so much!

1 Like