How to add component to gameobjects in array?

public GameObject[] go; /variable

 go = GameObject.FindGameObjectsWithTag("CardField"); /start function

now it should go like this go.AddComponent("SomeScript"); / But This is not working...

Im using this to get gameobjects of card holders. Now i want to add a script to all of them automaticly on start game script. How can i do that?

Your current script is trying to add ‘a’ component to the array, not to each game object. Iterate through the array and for each object add the component.

for(int i = 0; i < go.Length; i++)
{
  go[i].AddComponent("SomeScript");
}

Would smth like this work?

GameObject[] objects;
		
foreach(GameObject go in objects)
{
	go.AddComponent<YourComponent>();
}

Both works perfectly! Thanks.