click first, click second, destroy if matched

Hi,I have a piece of code that generates 56 random cards.
At the moment are visible.
I want to click on one, click on a second one and if they are the same, destroy them and replace them with new ones. I thought about something like:

  1. generate all 6 cards
  2. click on the first cards
  3. click on the second card
  4. if first card == the second card
  5. store first one spawn point
  6. store second one spawn point
  7. destroy both
  8. generate and instantiate one card in one stored spawn point
  9. generate and instantiate second card in the other stored spawn point

The problem, is I don’t exactly now how to select the objects and compare them. Any suggestions?

Use onClick(); with an if statement that checks to see if the two cards are a match. That’s the simplest answer, assuming that your current code creates the same card object. Might help to post what you have so far.