Layer Mask not working

I have read articles and other peoples posts about layer masks, and I can’t get this to work. I am testing to see if a point in my game is within an objects mesh. So I found this code that easily does this:

Now am adding a layer mask to the one and only object I want to test if my coordinate is inside of (Nothing else in my game should affect the ray cast). I created a layer (layer 9 in this case) that my gameobject “sphere” is assigned to, and then used the code in the link above to test if my coordinate is within my “sphere”. But for some reason, the raycast is still affected by other objects in the game. Here is my code that I use to create the layer mask for anyone willing to help:

internal var hitObjectMask : LayerMask = ~(1 << 9);//this is the layer mask

internal var hitObject : GameObject; //This is the sphere that I talked about above.
hitObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
hitObject.AddComponent(MeshCollider);
hitObject.layer = LayerMask.NameToLayer("SpawnOutline");//this is the name of layer 9

And just in case your wondering, here is how im using the raycast:

if( Physics.Linecast(Point, Start, hit,hitObjectMask)) {

Sadly, I solved my own problem just 1 hour after posting. (Which is funny because I have been trying to solve this for 2 and a half days)

Anyways, All I was doing wrong is that is I want to only collide with layer 9, I need to do this:

internal var hitObjectMask : LayerMask = (1 << 9);

if( Physics.Linecast(Point, Start, hit,hitObjectMask)) {