NPC tween flips character?

I’m trying to make my character turn, but whenever I do it decides to flip and I don’t quite know how to fix it.
unknown_2022.11.15-19.19

hrp.CFrame = CFrame.lookAt(hrp.Position, Vector3.new(Nodes[index+1].Position.X,hrp.Position.Y,Nodes[index+1].Position.Z)) -- Works over here
		
		local distance = (Nodes[index].Position - Nodes[index+1].Position).Magnitude
		local timeToGetThere = distance/self.WalkSpeed
		local subNodes = math.floor(distance) / 0.5
		
		for subNode = 0,subNodes do
			
			local subNodePos = CFrame.new(Nodes[index].Position.X,hrp.Position.Y,Nodes[index].Position.Z):Lerp(CFrame.new(Nodes[index+1].Position.X,hrp.Position.Y,Nodes[index+1].Position.Z),subNode/subNodes)
			local nextNodePos = CFrame.new(Nodes[index].Position.X,hrp.Position.Y,Nodes[index].Position.Z):Lerp(CFrame.new(Nodes[index+1].Position.X,hrp.Position.Y,Nodes[index+1].Position.Z),((subNode+1)/subNodes))
			hrp.CFrame = subNodePos * CFrame.Angles(0,math.rad(hrp.Orientation.Y),0) -- My guess is something over here bugging it?
			nextNodePos *= CFrame.Angles(0,math.rad(hrp.Orientation.Y),0)
			if subNode ~= subNodes then
				enemyMovementRemote:FireAllClients(hrp,timeToGetThere/subNodes,nextNodePos)
			else
				enemyMovementRemote:FireAllClients(hrp,timeToGetThere/subNodes, CFrame.lookAt(hrp.Position, Vector3.new(Nodes[index+1].Position.X,hrp.Position.Y,Nodes[index+1].Position.Z)))
			end
			
-- Doesn't work over here
			task.wait(timeToGetThere/subNodes)
			
		end

It looks like you have your nodes at ground level and the HRP is trying to look down when it passes over the node.

Do you know how I can prevent this from happening?

Raise the nodes.
30charactroonies

Raising the nodes unfortunately didn’t help.
local nextPartToCharRelation = Vector3.new(Nodes[index+1].Position.X,hrp.Position.Y,Nodes[index+1].Position.Z)
This should make the Y the same so it doesn’t look upside down right? But when I use this:
enemyMovementRemote:FireAllClients(hrp,totalTime, CFrame.lookAt(hrp.Position, nextPartToCharRelation))
It still makes it go upside down

I don’t really understand too much of this, something to do with how lerping works? If possible could you elaborate ?

You can set which direction is up when you’re making a new cframe with lookat:

lookAt(at: Vector3, lookAt: Vector3, up: Vector3)