Enemy destroys player if scale is bigger

void OnTriggerEnter2D(Collider2D other)
{
//if the object is a Collectable
if (other.gameObject.CompareTag (“Star”))
{
if (transform.localScale < other.transform.gameObject.localscale)
{
}
//Destroy gameObject
other.gameObject.SetActive (false);
//Increase player size when ‘eating’ pick up
transform.localScale += new Vector3 (0.2f, 0.2f, 0.2f);
}
}

I have this code and I so far made it able to grow when destroying the enemy(Star) but I now want it to detect if the “Star” is bigger than the “Player” and if so, destroy the player instead. I dont think
[if (transform.localScale < other.transform.gameObject.localscale) ] is the right type of code to be using but I can’t find anything on the forums to help. Anyone know this issue?

Try to change your condition as follow :

if (transform.localScale.sqrMagnitude < other.transform.gameObject.localscale.sqrMagnitude )