Sidescroller character doesn't collide with moving obstacle

In this sidescroller I’m making, I’m trying to make a moving obstacle that moves in and out on the x axis to push the player off the y axis. When ever my player goes in front of the moving block, they don’t collide with each other and the sidescroller character fazes through the moving block (like in the picture shown). I would like to know how to fix this. I’m guessing it has something to do with being locked on the y axis but i can’t find out how to unlock it. Please help me as soon as possible.