Dummy flipping around when using lookAt()

I’m trying to program a dummy which can continue looking at a player as they move around.

I have nailed that part and it’s working fine.
However as the player jumps over the dummy, the dummy flips around and faces upwards in the Y axis.

My code:

local lookAt = dummy.HumanoidRootPart.CFrame:PointToWorldSpace(Vector3.new(0,0,-3)):Lerp(player.Character.HumanoidRootPart.Position, .1)

dummy.HumanoidRootPart.CFrame = CFrame.lookAt(dummy.HumanoidRootPart.Position, lookAt)

Video:

1 Like

Remove the Y axis from the lookAt position.

lookAt = lookAt * Vector3.new(1,0,1)

Try this.

local lookAt = dummy.HumanoidRootPart.CFrame:PointToWorldSpace(Vector3.new(0,0,-3)):Lerp(Vector3.new(player.Character.HumanoidRootPart.Position.X, dummy.HumanoidRootPart.Position.Y,player.Character.HumanoidRootPart.Position.Z), .1)

dummy.HumanoidRootPart.CFrame = CFrame.lookAt(dummy.HumanoidRootPart.Position, lookAt)
1 Like

Thanks for the reply.

Unfortunately, when I tried implementing your solution I experienced very unexpected results.
Such as:

  • Dummy spinning indefinitely
  • Dummy facing incorrectly

I’m guessing you were mentioning the “PointToWorldSpace(Vector3.new())” line?

Thanks, this worked!
Appreciate the response :slight_smile:

1 Like

No problem. Sorry it took me awhile to respond. It took awhile to type on mobile.

(Also thanks for the solution. It’s my first.)