How do i lock the player character in a position with a mesh, and then unlock and walk around when i press a button?

How do I do the same for firstperson?