UI button will not appear after player has died! - c#

So what I’m trying to do is make a UI button appear when I set the player.SetActive(false)
I can’t see a problem with my code and I don’t get any errors. Can anyone see anything wrong with it.

Code:

void Respawn()
	{
		PlayerPrefs.SetInt ("lives", PlayerPrefs.GetInt ("lives") - 1);
		//DontDestroyOnLoad (transform.gameObject);
		Livestext ();
		Application.LoadLevel(Application.loadedLevel);
	}
	void OnCollisionEnter2D(Collision2D coll)
	{
		if(coll.gameObject.tag == "Enemy")
		{
			player.SetActive(false);
			LoseText ();
		}
	}
	void OnGUI()
	{
		if(player.activeInHierarchy == false)
		{
			if(GUI.Button(new Rect(10, 10, 50, 50), "Try again?"))
			{
				Respawn();
			}
		}
	}

As you check for the ‘enemy’ tag in the collision method, I assume the script is attached to the same object (the player) which is referenced by your player variable. That would make the script set its own object to be inactive and thus OnGUI won’t be called anymore.

Otherwise:
Another point of failure could be the tag - make sure it’s spelled correctly and that the object you’re trying to collide with is tagged with exactly this tag.

Also make sure that both objects have a 2D collider attached to them and at least one of them needs a rigidbody or some component that can cause an execution of the collision and trigger messages.