Layer Mask Not working to open the door

So i created a layer mask so i can open the door when im close to it but it wont work. code compiles and everything though. I created a cube made it into a ray got rid of render on the cube so user cant see it and put it as the doorout : transform and the target is my game character FPS. heres my code

var target: Transform;
var doorout: Transform;
var area: int=100;
var speedOpen: int=1000;
var speedClose: int=-1000;
var angleClose: int;
var angleOpen: int;

function Update(){

    var layermask =1 << 8;

    var forward = (doorout.transform.TransformDirection(Vector3.forward));

    if (Physics.Raycast(doorout.transform.position, doorout.transform.forward,area,layermask)){

    if (transform.localEulerAngles.y < angleOpen){




Unless you're really married to this approach, the standard way of doing it is using a proximity sensor. You make that by putting a collider (Box collider is nice) as the proximity volume, set that to Is Trigger, and use the OnCollisionEnter function to trigger your animation/sound/etc.