How to stop my sword from hitting myself

I am trying to get my player to swing his sword and hit other players in a network game. Currently my sword during idle and swinging animations collides with my character and begins to take away his health.

I can’t change my tag to “Player” and everyone as “Enemy” because all the players in the game will be real players.

How can I find out if my collider is attacking myself and stop it before it does?

I’ve read about raycast and ignoring collisions but I’m not firing a bullet.

disregard solved my problem.

collider.transform.root;