while true do ClosestHead=nil ClosestDistance=MaxDistance CharacterHeads={}for Y,Q in pairs(workspace.Characters:GetChildren())do if Q:IsA("\077\111\100\101\108")and Q:FindFirstChild("\072\101\097\100")then table.insert(CharacterHeads,Q.Head)end end for Y,Q in pairs(CharacterHeads)do Distance=(Q.Position-NPCHead.Position).Magnitude if Distance<ClosestDistance then ClosestDistance=Distance ClosestHead=Q end end if ClosestHead~=nil then(TweenService:Create(NPCHead,TweenInfo.new(.5),{CFrame=lookAt(NPCHead.Position,ClosestHead.Position)})):Play()else(TweenService:Create(NPCHead,TweenInfo.new(.5),{CFrame=OriginalHeadCF})):Play()end wait()end


while true do
    -- Get closest character head
    ClosestHead = nil
	ClosestDistance = MaxDistance
	CharacterHeads = {}
	for _, Character in pairs(workspace.Characters:GetChildren()) do
		if Character:IsA("Model") and Character:FindFirstChild("Head") then
			table.insert(CharacterHeads, Character.Head)
		end
	end
	
	for _, Head in pairs(CharacterHeads) do
		Distance = (Head.Position - NPCHead.Position).Magnitude
		
		if Distance < ClosestDistance then
			ClosestDistance = Distance
			ClosestHead = Head
		end	
	end
    
    -- Look at closest character head or reset to original position if none found 
	if ClosestHead ~= nil then        
		-- Look at
		TweenService:Create(NPCHead, TweenInfo.new(0.5), {CFrame=lookAt(NPCHead.Position, ClosestHead.Position)}):Play()
    else 
		TweenService:Create(NPCHead, TweenInfo.new(0.5), {CFrame=OriginalHeadCF}):Play()
    end
    
	wait()    
end
