How would i prevent my player from looking behind himself

hello i have made a wardrobe hiding script like in the game “Doors” and in the game doors when u are hiding u can’t look behind ur self only down, left, right, up, and forward but how would i do that?