How to get the string variable of parent object

I am trying in my script to set a gameobject variable to that object’s parent I am trying to use transform.parent with Gameobject.Find() but Gameobject.Find wants a string variable how can I turn UnityEngine.transform to a string or get the string value of my object’s parent

Hey there,

what you are looking for is probably something along the lines of this:

transform.parent.GetComponent<YourGameobjectType>().YourVariableName = "this is the string that i put in there";

You should probably look a bit into the basic tutorials which are provided by unity in form of video lessons. There the basic principles of programming scripts in unity should become clearer to you.

Hope this helps.

EDIT:

This assumes that you have a custom class/script of name “YourGameobjectType” on the parent. This class then has to have a public string property of name “YourVariableName”. Ofc the names are only for demonstration purposes.