How to make collision check. of position behavior. And to push the player back.

How do you make a collision with a position block? On a grid and Y+ and X+ to push the player back if go goes out of the border?

Screen Shot 2020-07-25 at 22.20.05