Why isn't my Nexus 5 able to connect to wifi?

A

AC Question

Hi! My Nexus 5 started going crazy

My Nexus 5 started going crazy by not connecting to the Wi-Fi. I cannot turn the Wi-Fi back on too. I tried setting the bandwidth to 2.4 GHz like what others said from different sources but still did not work. Now, every time the screen goes to sleep mode or when I press the lock button, it turns off right away then turns on then turns off. I already did a factory restore twice. What should i do next?