Text change from parent

Say, I have a Capsule with a child Text GameObject. How do I change the text of the child using a script in Capsule?

    public class Capsule:MonoBehaviour
    {
        [SerializeField]  //Drag the object into this field on the inspector 
        private Text Text;

        private void Awake()
        {
            //or get the reference while the script is awaken
            Text = transform.Find("Text").GetComponent<Text>();
        }

        public void SetText(string str)
        {
            Text.text = str;
        }
    }