CFrame.lookAt() issue

I want an enemy to look at the player without setting its position, I just want the orientation to change. Its jittering around very weirdly which I do not like.

Is there any alternatives to CFrame.lookAt() that only set the orientation and nothing to do with the position? (i tried setting the orientation but i dont know enough math to get the orientation to lookat the player)

something i tried:

			   if Config.turn == true then
					local tw = game.TweenService:Create(script.Parent.HumanoidRootPart,TweenInfo.new(0.05,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false),{CFrame = CFrame.lookAt(script.Parent.HumanoidRootPart.Position,v.Character.HumanoidRootPart.Position)})
					tw:Play()
					tw.Completed:Wait()
					script.Parent.Humanoid:MoveTo(v.Character.HumanoidRootPart.Position)
				end
1 Like

To just rotate the enemy try the following:

local enemy = script.Parent   -- assumption
local rotateCFrame = CFrame.lookAt(enemy.HumanoidRootPart.Position,  Vector3.new(v.HumanoidRootPart.Position))
local tw= TweenService:Create(enemy.HumanoidRootPart, rotateTweenInfo, {CFrame = rotateCFrame})
1 Like

This fixed nothing, it actually made it worse because while it does turn, it doesn’t move. Also, there are a few errors in this code.

1 Like

You are using CFrame.LookAt(). CFrame.new() is what you want.
using cframe.new(vect3,vect3) will make a cframe that has the position of the first argument and have the rotation to look at the second.

CFrame | Documentation - Roblox Creator Hub

The only change you want to make is change lookat to new