How to set distance?

(JAVASCRIPT)
I want to make it so you have to turn off a transformer. So far I have this:

#pragma strict

function Start () {
		light.color = Color.cyan;
}

function OnMouseOver ()
{
	if 
    	if ( Input.GetMouseButtonDown(0))

        {  
           light.color = Color.red;
        }
    }

This script is of course incorporated with the light, not the transformer itself.
(Check images for before and after)

Image and video hosting by TinyPic

          Notice how far I am. I want to make it so you stand, for instance, a yard away, at most.

var player : Transform;
var minDistance : float;

function Start () {
        light.color = Color.cyan;
}
 
function OnMouseOver ()
{
    if ( Input.GetMouseButtonDown(0) && Vector3.Distance(transform.position, player.position) <= minDistance)
        {  
           light.color = Color.red;
        }
    }

that should work, let me know if it works!