Can I make this 'if' to not kill a player?

I am making a Unity Playground platformer based on Player changing colour (changing a character for a different colour) and I want to make certain terrains to kill every other colour than the “right” one.
I tried to modify an existing script (ModifyHealthAttribute) to look for a yellow player but it kills it no matter if yellow or not.
Can you help?

using UnityEngine;
using System.Collections;

[AddComponentMenu(“Playground/Attributes/Modify Health”)]
public class ModifyHealthAttributeElectric : MonoBehaviour
{

public bool destroyWhenActivated = false;
public int healthChange = -1;


private void Reset()
{
	Utils.Collider2DDialogWindow(this.gameObject, true);
}


private void OnCollisionEnter2D(Collision2D collisionData)
{
	if (collisionData.collider.name == "Electric")
	{
	//Don't kill a Player
	}
	else
	{ OnTriggerEnter2D(collisionData.collider); }
	
	
	
}

private void OnTriggerEnter2D(Collider2D colliderData)
{
	HealthSystemAttribute healthScript = colliderData.gameObject.GetComponent<HealthSystemAttribute>();
	if (healthScript != null)
	{
		// subtract health from the player
		healthScript.ModifyHealth(healthChange);

		if (destroyWhenActivated)
		{
			Destroy(this.gameObject);
		}
	}
}

}

Personally I would do tags and name the tags for each color and then in the scripts say if tag=“Yellow” or what ever color to damage, that way it ignores all the other colors.

you can also set an object to temporarily disable the collider which will allow the character to pass without damage.

Either way should work.

I already use tag “Player” for all colors so the camera can follow them even if they change. Also I need to kill everything except yellow or “Electric” as I call it.