How to put ".transform" after "GameObject.FindGameObjectsWithTag()"

So I am trying to do this:

bush = GameObject.FindGameObjectWithTag("Bush").transform;

But with this:

bush = GameObject.FindGameObjectsWithTag("Bush").transform;

But for some reason, trying to find GameObjects with the tag and putting “.transform” after it won’t work… I tried removing the “.transform” after it and putting a foreach statement after it, like so:

foreach (GameObject bushes in bush)
{

bushes.transform();

}

But it still doesn’t work. So I came here, and would appreciate the help. :slight_smile:

[FindGameObjectsWithTag()][1] returns an array of all objects found.

You would need to use [for][2]:

bushes = GameObject.FindGameObjectsWithTag( "Bush" );

for ( int i = 0; i < bushes.Length; i++ )
{
    print( bushes*.transform )*

}
or [foreach][3]:
bushes = GameObject.FindGameObjectsWithTag( “Bush” );
foreach ( GameObject bush in bushes )
{
print( bush.transform )
}
or you can gamble on the first one by using:
bushes = GameObject.FindGameObjectsWithTag( “Bush” );
print( bushes[0].transform );
or even:
print( GameObject.FindGameObjectsWithTag( “Bush” )[0].transform )
[1]: Unity - Scripting API: GameObject.FindGameObjectsWithTag
[2]: Iteration statements -for, foreach, do, and while | Microsoft Learn
[3]: Iteration statements -for, foreach, do, and while | Microsoft Learn