I would use tags instead of layers. If you are looking to detect enemy hit collision with raycast, layers are generally not the best method.
Call FireWeapon()
whenever you want to fire a Raycast. Create a new layertag in the unity editor called "Enemy". Whenever the ray hits a collider with the tag assigned Enemy, you should be able to handle whatever commands needed. RealisitcallyRealistically, you can just use my raycast if check in your current function if everything is working as it should. The ray will be forward out from the cameras front direction.
Please let me know if I can be of any further help
void FireWeapon() {
//Created a camera type with name PlayerCamera
float weaponRange = 150f;
if (Physics.Raycast(PlayerCamera.transform.position, PlayerCamera.transform.forward, out RaycastHit hit, weaponRange)) {
if (hit.collider.CompareTag("Enemy")) {
// Decrease health
}
}