Code not working as intended

I don't know why but it fixed the problem. THANK YOU!