Trying to move head of NPC character to look at the object

I am making a simple linesman AI which moves on the Z axis and I want the head to face the ball, I have tried using look at but it is somehow messing with the HumanoidRootPart Position and is not going to the waypoints and is basically going backwards, any help is appreciated.

while true do
	wait()
	local target = workspace.TPS
	followPath(Vector3.new(character.PrimaryPart.Position.X, character.PrimaryPart.Position.Y, target.Position.Z))
	character.Head.CFrame = CFrame.lookAt(Head.Position, target.Position)
end

https://gyazo.com/beafb688e4623c7a20ced69d5b01d7af

2 Likes

When making a CFrame using CFrame.new() the parameters are:

local cf = CFrame.new(origin, target)

Which will create a CFrame positioned at the Vector3 origin looking towards the target at the Vector3 target.

Try changing CFrame.lookAt() to CFrame.new(). This will be the easiest solution, if it works.

1 Like
workspace.ChildAdded:Connect(function(object)
	if object:FindFirstChildOfClass("Humanoid") then
		local ik = Instance.new("IKControl")
		ik.Parent = object:FindFirstChildOfClass("Humanoid")
		ik.Target = workspace.Part
		ik.ChainRoot = object.Head
		ik.EndEffector = object.Head
		ik.Type = Enum.IKControlType.LookAt
	end
end)
1 Like

I have already figured it out didn’t realise the neck joint was in the torso of an R6 character I will probs test it out with CFrame.new to see if it works better

Wow, I didn’t know this was a thing! Thank you for sharing this!

1 Like

Np! I just found out about it a couple of days ago haha

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.