Destroying game object

I have a gameobject called item which has script attached to it
if (Input.GetMouseButtonUp(0))

My Gameobject has several child objects. I want to destroy the child object which gets clicked.
But the above code destroys parent object as well as the child object. Anyway to only destroy child object??

There are 2 ways to do this:

  1. Move your script to each child object, so they are destroyed individually. Each child will have a copy of the script and it will handle being clicked/destroyed.

  2. Raycast from the camera to the pointer, get the clicked object, check for a tag on it or something (your logic here), and then destroy it if needed. Info here, and here.