Orientate a rig's head to player's Head

I’m trying to make a rig constantly look in the player’s direction (specifically at their head) and I’m using RunService.Stepped() to do it, but it isn’t working.

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.CharacterAdded:Wait()

local startPosition = script.Parent.Position
local targetPosition = Character.Head.Position

RunService.Stepped:Connect(function(time, deltaTime)
	script.Parent.CFrame = CFrame.new(startPosition, targetPosition)
end)

There aren’t any errors

Stop advertising your antivirus plugin all over the forum, this isn’t anything to do with any virus.

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

is this a server script or a local script?

LocalScript as a child of the rig’s head.

1 Like
script.Parent.CFrame = CFrame.new(startPosition, targetPosition)

needs to be updated to

script.Parent.CFrame = CFrame.lookAt(startPosition, targetPosition)

Because this is the new version.

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

have you made sure the head is not welded to anything?

That’s interesting, because the DevHub uses CFrame.new() when orientating. Using lookAt doesn’t change my issue either.

Adapting the CFrame will bypass any welds used.

Stop advertising on my threads.

I got it to work in a private world by doing this:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		game:GetService("RunService").Stepped:Connect(function()
			script.Parent.CFrame = CFrame.lookAt(script.Parent.Position, character.Head.Position)
		end)
	end)
end)

– Server script inside the NPC head.

You have to remove the neck weld btw in the player head.

This was on R15 as well.

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

Also @m_orbidlyfat report this guy lol. Everybody report him.

try adding a print in the loop and check if its running at all

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

If I use a ServerScript wouldn’t it update for every player though? Like If player 2 shows up first, then player 1 shows up, the rig will focus on player 1
image

Oh right yeah sorry this should work in a local script to. Just make sure the local script is in player scripts otherwise it will not run.

Oh wait that might be the problem lol

Make sure your script is in player scripts.

I want you to stop posting about your crapfilled antivirus.

I have done, many times

And using LocalPlayer in a localscript instead of PlayerAdded is a more efficient way of getting the player.