[SOLVED]Why doesn't this code work?

I have a line of code that works perfectly:

gameCamera.GetComponent<CameraController>().cameraTarget = SelectedPlayer.transform;

I then have this code that should do the same thing:

gameCamera.GetComponent<CameraController>().cameraTarget = army.selectedArmy[character].gameObject.transform;

In the second line I am trying to get the camera to focus on a game object by clicking a UI button and it focuses on an object depending on it position in the list “selectedArmy”. what ends up happening in the second line of code it the camera focuses on where the gameObject originally instantiated in the scene instead of the gameObject itself.

I fixed it.