How to make collision check if other collider has component

Hi! I've quite recently started learning javascript and I still have quite some trouble with it. I'm currently working on a RPG-game and have started a test scene, it contains:

EnemyCube <- Atm static cube, with a box collider and a script that senses if mouse is over it and makes it change colors aswell as mouse cursor-texture. If mousebutton is pressed when it's hovering over it the variable "selected" is changed from 0 to 1.

PlayerCube <- Moves to where the mouse is clicking, it has a box collider aswell as an empty child-object with a sphere collider ("RangeCollider"), I want the rangecollider to kick in when it senses another Collision, I want it to check if the other colliders object is tagged with the tag "monster"

In case the tag is "monster" I want it to read if the "selected" variable is 1 in the EnemyCubes script, in that case I also want the PlayerCube to call "function isInCombat()"

My problem is the part where I want my "RangeCollider" to look if the other collider has the EnemyScript and if that scripts "selected" variable is set to 1. I'm kinda clueless.

This is just a quick-and-dirty untested approach, but hopefully it explains the concepts.

function OnCollisionEnter ( hit : Collision )
{
  if ( hit.gameObject.tag == "monster" )  // did we collide with a gameObject tagged 'monster'
  {
    var monster = hit.gameObject.GetComponent(EnemyCube);  // store the EnemyScript to a local variable

    if ( monster )                        // if we found an EnemyScript on the monster
    {
       if ( monster.selected == 1 )       // if the monster's selected value is 1
       {
          // Do your thing
       }
    }
  }
}

By the sounds of things, all you were missing was the GetComponent call to find the EnemyScript. If you're unable to work this into your code, post what you have and I can adapt it to your approach.