well looking at the code the places where you may get a null value that you are not checking for are
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var script = hit.collider.gameObject**.GetComponent(“Door”)**;
Camera.main might be null.
If theres no Door component on the hit object that would be null.
before you set ray do this
if( Camera.main ) {
// rest of function
}