Help with sprite taking

I need some help with my sprite taking system. I’m trying to make chess with as little extensions as possible. For some reason, when it’s the other player’s turn, the opponents sprite goes on top of their sprite instead of getting destroyed.

Black’s turn(the turn that dosen’t work): https://makecode.com/_RL7bo29Mi5z0

White’s turn(the turn that works): https://arcade.makecode.com/S06121-76545-99433-83098