*sigh* I think i know what your going for with the quick and to the point suggestions, but more detail would be much appreciated. Your posted age would suggest a higher word count then 21. I would certainly love to learn the details behind this contraption, thanks and good luck.
so you have a carpet in front of your house with small wires going to a generator the idea is to shortly electrify or stun the first few players or zombies trying to go inside if you are the one living you can turn it off easily by a button or switch closeby @Crazypineapple55
The only way I could see this working is having a metal plate under that carpet but even then your enemies would be probably wearing rubber soled hiking boots so your enemies would have to be barefoot for this to work