How can I specify what I want something to collide with?

I am coding a game, and I want to check whether or not the main character's sword is colliding with stuff. I have a capsule collider attached to it, and seems to work well. I have a script that sends anything the sword collides with flying through the air. The problem is that randomly the sword will collide with my character and send me flying off the terrain forever. Is there any way to prevent this from happening, or somehow specify what to collide with?

Haha nevermind, I just figured out. You just use the Physics.IgnoreCollisions function.

Garret Chase - do you think you could post that script i am making a similar game yet i dnt no anything about scriptin. plz post it THNKS

Sure here is the code I was using:

function OnTriggerEnter(other : Collider) {

Physics.IgnoreCollision(GameObject.Find("Main Character").collider, collider);
Debug.Log("I Hit Something!!!!");

}

Hope that helps