I want to make this dude look at me

  1. I want the NPC to look at me. Not turn their entire body. Just the head.
  2. I want it to look like he turned his head, not like it just snapped there immediately.

But yeah, I want to make this NPC turn his head towards the player somehow (as well as meet the criteria above). How do I do this?

1 Like

Change the C0 property of the Neck weld.

1 Like

neck weld? you mean motor6d? also would i just use a cframe that has the same position, but a new orientation?

I think C0 has orientation only, and C1 is for position. You just need to convert world space to object space.

Same thing. For animators, it’s completely different.

1 Like

SimTek has a tutorial video on this very question.

Put this inside of the dummy’s head:

function getClosestPlr()
	local range = math.huge -- Set the range the dummy can look for players within --
	local targets = {} -- A table for potential targets to look at --
	local target = nil -- We will update this to the player's position later --
	for i,v in pairs(workspace:GetChildren()) do
		if v:FindFirstChild("Humanoid") and not v.Name == "Dummy" then -- Just make a if/then statement to check if v is not the dummy looking at the player--
			table.insert(targets, v:FindFirstChild("Head")) -- Add the head's position into the table--
		if #targets > 0 then
			for i,k in pairs(targets) do
				if (script.Parent.Position - k.Position).Magnitude < range then
					target = k -- Sets the target to look at the player's head--
					range = (script.Parent.Position - k.Position).Magnitude -- Inserts the distance between the dummy and the player's head--
	return target

while wait() do -- This loop continuously searches for the closest player and looks at the player's head.
	local target = getClosestPlr()
	if target then
		script.Parent.CFrame = CFrame.new(script.Parent.Position, target.Position)

This might not be the best method, but it works smoothly for me.

Hope you found this useful :slightly_smiling_face:

There is no need to use while wait() do. Use Heartbeat.

1 Like

This doesn’t change the neck’s C0/C1 properties, just points the head in the direction, along with the rest of the NPC.