character selection, 1 character not working

Hello
I have a character selection page, where both of my characters are tagged as player
when they go to the next scene, one of the characters works with the script while if i select the other character, the code does not work. The code searches for the tag ‘player’ to allow things to manipulate. only 1 character works. both have the same scripts attached. Does anyone know what ive done wrong?

	// Use this for initialization
	void Start () {
		playerOBJ = GameObject.FindWithTag("Player");
		playerScript = playerOBJ.GetComponent<PlayerController>();

		
		float xPos = Screen.width - 950;
		float yPos = Screen.height * 0.4f;
		

		GameObject.Find ("_NotePad").guiTexture.pixelInset=new Rect(xPos,yPos,275,200);

	
	}
int monitor = 0;

	void Update () {




		if(playerScript.questionNumber > monitor){
		a = Random.Range(1,5);
		b = Random.Range(1,5);

			string s_a = a.ToString();
			string s_b = b.ToString();
			GameObject.Find("GUI-questions").guiText.text = a + " + " + b;






			monitor++;


		}

When you do a GameObject.FindWith Tag(). If there is more than one GameObject of the same tag in the level, it will stop searching after it’s found the first one. Meaning it doesn’t matter what GameObject you attach the code to. It will still come back with the same Player.

If you look through the classes you’ll find there are two similar functions:

GameObject.FindGameObjectsWithTag
GameObject.FindGameObjectWithTag

One will look for one, as soon as it finds it and then stops searching. The other will collect a list of all of the objects with the same tag.

To fix this either give them different tags (Player_One, Player_Two), or search using all GameObjects and find the one of reference (more complicated).

Either way that’s where you’re going wrong I think :slight_smile: