Did you make that logic? You should know how to solve this if you made it, I tried to work it out and it alters your position variable when you hold a key down it allows you to place on the position held by the player, so you need to work out when that is happening and disable the space or shift key.