How to assign a layer to a Collider 2D

Hey ! i am implementing a parry system in my Metroidvania 2D game.

I made it like that → if i the player do the parry a the good time, he dont take damages, so when the collider of the parry touch the collider of the ennemy attack, the player success his parry. The problem now, is that i created colliders into my scripts, and so, i assign to the parry one a layermask "Parryable", to detect from wich layer is the attack collider BUT i dont know how to assign a layer to a collider… I found somewhere that we can use that type of code

attack.gameObject.layer = LayerMask.NameToLayer("Parryable");

to assign a layer to a collider BUT, now, when my player get hit by the enemy attack, his own layer come from "Player" to "Parryable", so he begin to go through the ground lol… Nevertheless, the parry system works ! but i go through the ground


// past code here