Set public Gameobject based on which game object entered a Trigger?

so i gave this pice of code:

public GameObject player;

    void OnTriggerExit (Collider myTrigger) {
    		if(myTrigger.gameObject.tag == "Player"){
    			Debug.Log("Box went through!");
    			isPlayerVisible = false;

that works pretty fine, i get the debug log and so on.
what i want to do now is, that the triggered gameobject gets set as the " public GameObject player;"

I’m sure you could’ve figured this one out yourself. :')

player = myTrigger.gameObject;