How do i find a bone on my character within a script?

Ive been trying to reference the “Head” bone on my character object but when i play the game it says “Cant Find HEAD” instead of “Found HEAD”.

I’ve tried changing the path names and it doesn’t seem to do anything, I’ve also tried changing the object of which the script is placed on but that hasn’t changed anything either.

I’ve noticed that the bones are not shown in the hierarchy tab but they are shown only when i go into the configure option of inspector. does this have something to do with not finding the bone?

any help is greatly appreciated !

!!! ANSWER !!!** Okay, I found out what was wrong. as @Priyanka-Rajwanshi explained, the above code would work only if the bone is shown within the hierarchy. Since I have “Optimize Game Objects” active on my player model’s Rig, I had to add which bones I could control (add to the hierarchy) under “Extra Transforms to Control”. **

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class head_rotation : MonoBehaviour {

	private Transform head;

	void Start () 
		head = transform.Find("Head");
		if (head)
			Debug.Log("Found HEAD");
			Debug.Log("Cant Find HEAD");
	void Update () 

simply try:

player_head = GameObject.Find("Head");

@Fibonacci_0_1_1 Try:

 player_head = transform.Find("Head");