Problems to change text from a child in a child

Hey guys, I have problems to change a text from a child of a child of another object

This is my hierarchy:


My script is attached to the “Schlafsack(Clone)” and I have to change the text from the Tooltip child “Text”.

This is the Code I tried but it didn’t work.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class Schlafsack : MonoBehaviour {

SpielerWerte spielerwerte;

float distance;

GameObject hud;
GameObject tooltip;
Text text;

// Use this for initialization
void Start () {
	spielerwerte = GameObject.FindGameObjectWithTag("Player").GetComponent<SpielerWerte>();
	hud = GameObject.Find("HUD");
	text = hud.transform.GetChild(5).GetComponentInChildren<Text>();
	//text = tooltip.transform.GetChild(1).GetComponent<Text>();

// Update is called once per frame
void Update () {
	distance = Vector3.Distance(GameObject.FindGameObjectWithTag("Player").transform.position, this.transform.position);

	if(distance < 5){
		text.text = "Press E to sleep in Sleepingbag";
			spielerwerte.sleep = true;


Thanks for help :slight_smile:

GetChild index starts at 0, not 1, so you should use GetChild(4) in order to be able to access Tooltip.