Basically what i’m doing is just setting the CFrame to face the player, however because of how CFrame.new() works it rotates on all axis’s. I just want it to rotate on the y. I have heard of fromMatrix() but I don’t understand it and I am not sure if that even is the solution.
How do I fix this?
local path = game:GetService("PathfindingService"):CreatePath()
local offset = char.PrimaryPart.Position + Vector3.new(0,0,10)
path:ComputeAsync(script.Parent.HumanoidRootPart.Position, offset)
script.Parent.Head.Neck.C0 = CFrame.new(0,yOffsetNPC,0) * CFrame.Angles(0,0,0)
local waypoints = path:GetWaypoints()
for k, v in pairs(waypoints) do
script.Parent.PrimaryPart.CFrame = CFrame.new(script.Parent.PrimaryPart.Position, char.PrimaryPart.Position)
script.Parent.Humanoid:MoveTo(v.Position)
script.Parent.Humanoid.MoveToFinished:Wait()
end
script.Parent.PrimaryPart.CFrame = CFrame.new(script.Parent.PrimaryPart.Position, char.PrimaryPart.Position)