Unity crash on collision

Hello,
My unity keeps crashing when the shuriken prefab collides with the box collider 2D prefab on my background.

It happened after I implented this while loop which I’m not confident on, so any help is appreciated…

private Rigidbody2D rb2d;
public float speed;
public GameObject Shuriken;
private int livess = 3; 
void Start ()
{
	rb2d = GetComponent<Rigidbody2D> ();
}
void Update () 
{
	rb2d.AddForce(Vector2.left*speed);
}
void SpawnShuriken()
{
	Vector3 RandomSpawn = new Vector3 (Random.Range (10.07F, 10.07F), Random.Range (-4.07F, 4.07F),1F);
	Instantiate (Shuriken, RandomSpawn, Quaternion.identity);
}
void OnTriggerEnter2D(Collider2D other)
{
	while (livess>0)
	{	
		if (other.gameObject.CompareTag ("Player")) 
		{
			if (livess <= 0) 
			{
				Destroy (GameObject.FindWithTag ("Player"));			
			} 
			else 
			{
				livess = livess-1;
				Debug.LogError (livess);
				break;
			}
		}
	}
}
void OnTriggerExit(Collider2D other)
{
	if(other.gameObject.CompareTag ("Background"))
	{
		SpawnShuriken ();
		Destroy (Shuriken);
	}
}

}

@plumel You have an infinite loop. Your application probably don’t crash, but freezes due to being stuck in that while-loop.

We already know(?) that livess won’t go below 2 (strangely enough). So the loop just continues on and on and on.

Have you tried changing private int livess = 3; to public int livess = 3; ? To see if thats the cause of livess not decreasing.

EDIT: Might clarify. if (other.gameObject.CompareTag ("Player")) this is never true for the player (since other will be anything but the player, since this script is on the player). Thus you have an infinite loop.

@Salmjak Are you able to help with this at all? It’s almost the same issue as last time, but after I added the while loop (I though this might make it loops through all the options and breaks out when) it crashes when it hits the boxcollider2d attatched to the background tag and gameobject.