Help with making Model face position

I have a roaming system for pets in my game. A random point is chosen within the boundaries of the player’s plot and the pet’s CFrame is set accordingly. The pet is also angled back and forth to give the illusion of movement.

petModel:SetPrimaryPartCFrame(CFrame.new(newPosition2)
        	* CFrame.Angles(math.rad(newAngle),0, 0))

My problem is that I’m not exactly sure how I would make the pet orientate towards it’s destination. The model correctly lerps to newPosition2 and tilts as intended, but it is constantly facing one direction. Any help on how I could approach this would be a big help.

1 Like

Pet.CFrame = CFrame.new(Pet.Position, targetPosition)
this will set the pet to look at the targetPosition (target position being a vector3)

That method is apparently deprecated

Understanding CFrames doesnt say so on the API reference?

It might still be working, but when I tried just now it did not have the desired effect.

CFrame.lookAt(Vector1, Vector2) is CFrame.new(Vector1, Vector2) the latter is deprecated, the former is not.

CFrame.lookAt(petHead, newPosition2)

Something like this.

try fromEulerAnglesXYZ (character limit)

How would I implement this into the code I wrote above?

petModel:SetPrimaryPartCFrame(CFrame.new(newPosition2)
 * CFrame.fromEulerAnglesXYZ(math.rad(newAngle),0,0))