The first thing you need is to hook up the light, the transform of the cylinder, and the transform of the player. This can be done on any of the three, but attaching the script to the light would probably be the cleanest.
var cylinder : Transform;
var player : Transform;
//and the light is accessible with "light"
Put that into a script, save it, and attach the script to the light. You’ll see two “slots” on the script; drag the cylinder and player objects into the appropriate slots.
Then all you need to do is check whether the distance between them is less than a certain value.
var distanceLimit : float = 5.0;
function Update() {
if (Vector3.Distance(cylinder.position, player.position) < distanceLimit) {
light.enabled = true;
}
else {
light.enabled = false;
}
}