CFrame.new() orientation facing the wrong way

I’m trying to make my execute function make the player face towards the executed player’s head.

character.HumanoidRootPart.CFrame = CFrame.new(liveFolder[target].HumanoidRootPart.CFrame.Position, -(liveFolder[target].HumanoidRootPart.CFrame.LookVector))

When ran, it faces the wrong way no matter what I change the 2nd parameter to. (Even with rightvector or any other vector it will face this one direction)

image

Having him look at the head might be better in your case.

	local target = Vector3.new(liveFolder[target].Head.Position.X, character.HumanoidRootPart.Position.Y, liveFolder[target].Head.Position.Z)
	character.HumanoidRootPart.CFrame = CFrame.lookAt(character.HumanoidRootPart.Position, target)

The problem is that you are looking at a ‘vector’ (a direction) and not a point. You need to look at the target’s position and not their look vector.

1 Like

In addition to the previous replies use CFrame.lookAt() instead of CFrame.new().

https://developer.roblox.com/en-us/api-reference/datatype/CFrame

This constructor overload has been replaced by CFrame.lookAt, which accomplishes a similar goal. It remains for the sake of backward compatibility.

1 Like

I could not use the head as the vector to look at like in the previous reply because the player can just come up from behind the head of the downed player and face the wrong direction while executing. Thanks to your reply, I learned how lookVector works and I changed it to this:

character.HumanoidRootPart.CFrame = CFrame.lookAt(character.HumanoidRootPart.Position, liveFolder[target].HumanoidRootPart.CFrame.Position + -(liveFolder[target].HumanoidRootPart.CFrame.LookVector * 10))