How can i get this working properly?

Im trying to make a room accessible to certain people. I made a deathCount objective named Deaths. Now what I want is this: If a player has 0 deaths and is within 4 blocks of the doorway[20,107,298,20,108,298] then it fills up with air. If the player does not have 0 deaths and is within 4 blocks then it fills with iron bars.
I have classes set up to give the player 1 point to Deaths so no player with a class may enter the Class Selection room until the reset the class which i have commands set up for that as well.
Best Answer
"CB" = "command block"
The stuff like this
is explanation of the respective command block's commands
CB 1 and 3 are a clock. They are powering CB 2 and 4 20 times a second.
CB 4 detects anyone in a 4 block radius of the door (/testfor all players at coords x y z within radius r with a score minimum and maximum of 0
). This means that only people with a death score of 0 will trigger it.
When CB 4 is triggered, it turns the comparator on. This powers CB 5, which removes the door for the player to walk though (fill from coords x y z to other coords x y z with air
). When the player is out of range, the comparator turns off, and the redstone torch on, powering CB 6 (Same idea as CB 5
), closing the door.
On the far left the command block teleports anyone with a death score of one or above outside the box. (teleport everyone with near coords x y z with radius r with a minimum death score of 1 to other coords x y z
)
Pictures about "How can i get this working properly?"



10 Early Warning Signs Your Heart Isn't Working Properly
More answers regarding how can i get this working properly?
Answer 2
when you put the command in for the selector have it say @a[score_Deaths=0] this tells the game that if you have a score higher than zero, this doesn't apply to you
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Andrea Piacquadio, Erik Mclean, Ylanite Koppens, Andrew Neel