How to do the matches in a memory card game?

Hi everyone!
I’m making a memory card game. I made 2 planes and parenting them together so they make a single card,i made another one too. Then, i added a common back side texture from gui for both cards. Every card on Start() gets randomly its front texture like below (javascript)(on StartUp.js):

public var oPlane: GameObject;

function Start () {
var texturesCollection: Object[] = Resources.LoadAll("Front_Face_cards");
var range_1 = Random.Range(0,texturesCollection.length);

if(oPlane.Find("front_card_1") && oPlane.Find("front_card_2")){
	oPlane.Find("front_card_1").renderer.material.mainTexture = texturesCollection[range_1];
	oPlane.Find("front_card_2").renderer.material.mainTexture = texturesCollection[range_1];
}
}

Now, on each plane i attached this code on (Flip_card.js):

public var card_1: GameObject;
card_1 = GameObject.Find("card_1");

function OnMouseDown () {
	card_1.transform.localRotation.z = 180;
	CheckCards();
}

So that, every time i clicked on a card this card can flip (the camera shows from above).
Later on, i check for any similarities with those 2 cards by calling CheckCards(), which is below in detail (Flip_card.js continue):

function CheckCards(){

if((card_1.transform.localRotation.z == 180) && (card_2.transform.localRotation.z == 180 )){
		if(card_2.renderer.material.mainTexture == card_1.renderer.material.mainTexture){
			Destroy(card_1);
			Destroy(card_2);
		}
	}

Unfortunately, it’s not working. i can’t destroy my two cards after i flip them both. I stuck there, i checked most of the answers close to my problem here but no luck.
Where do i check if my cards are the same and then destroy them? On the script attached to one or both cards, or on Update(), or on Start()?
Thanx in advance!

(UPDATED)

I just tested this and your texture comparison code definitely works, so something else is wrong somewhere. I’d suggest removing the localRotation check temporarily and seeing if it works with just the texture comparison, if you haven’t done that already.

If the texture comparison is the broken part, is it possible that your material has multiple textures, or that you’re not checking the correct renderer?

So, I kind of forgot what I was doing while writing this, so it’s probably incomplete. This is a C# solution for handling and comparing cards. Might be a little over-doing it, but it’s not throwing any errors (in the inspector, haven’t bothered testing it in a scene.)

using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;

public class CardHandler : MonoBehaviour
{
	private int maxCards = 0; 									// Define yourself.
	private List<GameObject> cards = new List<GameObject>();	// Leave this
	private List<Card> cardHandlers = new List<Card>();			// Leave this
	private GameObject card1, card2;							// Leave these
	
	private void Start()
	{
		generateCards();
	}
	
	private void generateCards()
	{
		float x = 0, y = 0, z = 0; 				// Define these based on table layout.
		float cardWidth = 0, cardHeight = 0; 	// Define these based on your models size.
		
		for(int i = 0; i < maxCards; i++) 
		{
			Card newCard = new Card();
			cards.Add(freshCard(newCard, x, y, z));
			x += cardWidth + 20;
			y += cardHeight + 20;
		}
	}
	
	private GameObject freshCard(Card C, float x, float y, float z)
	{
		System.Random rand = new System.Random();
		GameObject newCard = Instantiate(C.card, new Vector3(x,y,z), C.card.transform.rotation) as GameObject;
		
		int cID = rand.Next(0, C.materials.Length);
		Material toSetMat = C.materials[cID];
		
		newCard.renderer.material = toSetMat;
		
		return newCard;
	}
	
	public void Update()
	{
		/* Your Click Logic */
		GameObject clickedObject = null;
			
		if(clickedObject) 
		{
			// If you've clicked a card
			foreach(Card k in cardHandlers) 
			{
				// iterate through cards
				if(clickedObject == k.card) 
				{
					// If the current card is the one you clicked
					if(k.isFlipped) 
					{
						// If it's already flipped, ignore the click
						continue;
					} else { 
						// Else flip it
						k.isFlipped = true;
						if(card1) 
						{
							// If this is not the first card flipped
							if(card2) 
							{
								// If this is not the second card flipped, ignore click
								continue;
							} else { 
								// Else set card two to clicked card
								card2 = k.card;
								if(card1 == card2)
								{
									/* Your logic on correct match */
								} else {
									/* Your logic on incorrect match */	
								}
							}
						} else { 
								// Else set card one to clicked card
							card1 = k.card;	
						}
					}
				} else { 
					// Ignore all other cards
					continue;	
				}
			}
		}
		
	}
}

public class Card : Component
{
	public GameObject card; 		// Define with your default card model. No material.
	public Material[] materials; 	// Define with your material list.
	private int cardID;				// Defines themselves.
	public bool isFlipped = false;	// Leave this
}