SendMessage via RaycastHit not working. PLEASE HELP!

Hi. I’ve created a simple script to universally trigger the “Action” function in any gameobject. For example, if I wanted to open a door by pressing “E” while looking at it, I would attach an “Open” script to the door with the function “Action.” However, I am receiving null results. Take a look.

The SendAction script:

#pragma strict

var RaycastDist : float = 5;
var action = 1;

function Update () {
	var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
	var hit : RaycastHit; 

	if(Input.GetKeyDown(KeyCode.E)) {
		if(Physics.Raycast (ray , hit, RaycastDist)){
			hit.collider.SendMessage("Action", action, SendMessageOptions.DontRequireReceiver);
		}
	}
}

The SelfDestruct script:

#pragma strict

var Cube : GameObject;

function Action(){
	Cube.transform.active = false;
}

Please tell me what is going wrong.

It looks like Action() doesn’t really need any variables. You can try leaving the variable blank.

hit.collider.gameObject.SendMessage("Action", "", SendMessageOptions.DontRequireReceiver);

And I do believe that “.active” doesn’t work anymore. Use SetActive(boolean).

Cube.SetActive(false);