Prefab instantiation not working well

I have an empty game object which has a script called “AllIn”.
I have a game object flag which has no script.
I have the player game object which has a script called Player, obviously.

When the player collides with the flag, its form changes. I did that by using the Exit2Dmethod.

The empty game object has a public float counter(equal to 0 on start). When the player touches the flag the counter is incremented.

I have a public GameObject in the player’s script which I assign in Unity as the empty game Object. I use the GetComponent method to get that counter and increment it on touching the flag.

I assigned the empty game object to the player object and it works right, the value changes! However, as a prefab, I can’t assign the object to the player unless it’s also a prefab, which I do! Now the problem lies in when the player changes form, the instantiated new form doesn’t change the value in the empty object. Also if I remove the player from the Scene(even after pressing apply) and put it the prefab back there, it doesn’t work either, it’s not missing, it’s just not working… What am I missing here?

Hope I’ve been clear!

void OnTriggerExit2D(Collider2D col)

    if (col.gameObject.tag == "Blue Flag")
        Instantiate(ChangesForm(), transform.position, Quaternion.identity);

This seems like a good place for GameObject.Find() or one of the similar functions.

You can call this in Awake() of the instantiated objects to find the objects for which it needs a reference.