local aimTweenInfo = TweenInfo.new(.1)
local lookAt = CFrame.lookAt(AIRoot.Position, player.Character.HumanoidRootPart.Position)
local aimTween = tweenService:Create(AIRoot, aimTweenInfo, {["CFrame"] = lookAt})
aimTween:Play()
aimTween.Completed:Wait()
This is fine, but if you jump, the enemy looks up at you, and by looks up, I mean rotates his body in ways that do not make sense to the laws of physics.
So basically, how do I keep the Y value constant, and make sure he only rotates his X and Z values?
It creates a CFrame (4x4 matrix) from 4 Vector3s (the last row of the matrix is (0, 0, 0, 1)), if you want to learn more about CFrames and matrices, you can look here
I know this is an old post but you can do something like this
local x = char.HumanoidRootPart.Position.X
local y = touched.Parent.HumanoidRootPart.Position.Y
local z = char.HumanoidRootPart.Position.Z
touched.Parent.HumanoidRootPart.CFrame = CFrame.lookAt(touched.Parent.HumanoidRootPart.Position, Vector3.new(x,y,z))
so you set the y value to the y value of the 1st object, it worked for me.