why does my script not work

so i made 2 scripts and assing it to 2 cubes: cube and cube 1.
normaly if you click on cube its set a value so that when you click cube 1 its dispear.
if you click cube 1 first it not gonna work.
so thats what i tried to make but its do not work and i dont now why

here are my scripts

the script for cube:

using UnityEngine;
using System.Collections;

public class script : MonoBehaviour
{

public int test = 0; // make the variable for the value
public void OnMouseDown() // when the user click
{
test = 1; //make the value of test 1
}
}

and here is the script for cube 1:


using UnityEngine;
using System.Collections;

public class NewBehaviourScript1 : MonoBehaviour
{
public GameObject a; //make a gameobject
public script script; //make a variable where we put in the script
void OnMouseDown() // when the user click
{
script = a.GetComponent(); // get script

if ( script.test == 1) //test or the variable test in the other script is 1
{
Destroy(gameObject); // destroy the object
}
}
}


can someon please help me

Please use code tags to make your script easier to read.

using UnityEngine;
using System.Collections;

public class script : MonoBehaviour
{

  public int test = 0; // make the variable for the value
  public void OnMouseDown() // when the user click
  {
    test = 1; //make the value of test 1
  }
}
using UnityEngine;
using System.Collections;

public class NewBehaviourScript1 : MonoBehaviour
{
  public GameObject a; //make a gameobject
  public script script; //make a variable where we put in the script
  void OnMouseDown() // when the user click
  {
    script = a.GetComponent<script>(); // get script

    if ( script.test == 1) //test or the variable test in the other script is 1
    {
      Destroy(gameObject); // destroy the object
    }
  }
}

It’s recommended that you not name the variable the same as the data type it represents (script variable for type script) as it causes ambiguity issues.
Also, how are you determining -which- cube is being clicked on? Looking at this script, the cubes only care that the mouse has been clicked. Doesn’t matter where.

OnMouseDown fires when you click on the object containing the script with that method (assuming it has a collider). So the assumption here would be that clicking on the cube with NewBehaviourScript1 would destroy that cube if the GameObject ‘a’ defined in the Inspector of NewBehaviourScript1 had a ‘script’ (lord these names are awful) and the value of ‘test’ on ‘script’ was 1. ‘test’ becomes 1 when you click on the cube that has ‘script’ on it.

It’s impossible to figure out what’s wrong because OP simply said it “didn’t work” which does nothing to describe the problem.

I have done the same jut than i wirite Script script and not script script.
And i tested first or its work if you click on it and itq worked thzn only if you click on the cube but are there other things wron too

And what i mean with dont work is that when i start the game for testing and i click the first cube and then the other cube it does nothing