Raycast that ignores object with certain tags?

Hi, im trying to make a turret script that detects players through raycasting. I got the raycast part working, but how do I make the raycast ignore certain objects with certain tags? The "ignore raycast" layer worked well, but it ignores every raycast made on it by my turret or other stuff like my player. I just want the object to ignore the raycast made by my turret. How do i do this with tags in javascript? Thanks!

:) Yes that's possible, found this answer awhile ago and it works well:

http://answers.unity3d.com/questions/3226/using-different-paricle-emitters-depending-on-the-tag-of-the-object-raycast-hits

I'm trying to use what you gave me, but i have no idea why it wont work. here's my code so far :

            if (hit.transform.tag == "Turret") {
Physics.IgnoreCollision(hit.collider, collider); 
    }

can anyone tell me where i did wrong?