Scaling using transform.Find?

I’m trying to scale an object that is a child of the button I am clicking, using the transform.Find code.

I have used very similar code to run scripts attached to the same object I am trying to scale now, so I could probably put the scale script in the object itself and just run it, but I was wondering if there was a simple reason why my code doesn’t work as is:

    new Transform test = transform.Find("Pushpin");
    test.localScale += Vector3(0.1,0,0);

first of all because you get error

it’s 0.1f not 0.1

  1. because you are making new Transform so it’s a new one not reference to that one

try this code:

Debug.log("We Are Here");
Transform test = transform.Find("Pushpin");
test.localScale += new Vector3(0.1f,0,0);

AND you MUST have a GameObject name “Pushpin” otherwise you’ll get NRE

and if debug doesn’t fire up You know you must change the way to fire your script, …

EDIT:

yes sorry it was typo it has to be new before Vector3

I edited the code and repair it