One way would be to make a variable that stores whether the player has the object or not (1 for yes, 0 for no) and make an On-overlap event on the barrier that checks the variable when the player sprite overlap it. If player is determined to have object then move him x number of pixels past, or teleport him to other side via a respawn event. Since the barrier can then stay solid the enemies will never be able to cross.