Wall only player can walk through

Hi Everyone, I’m completely new to unity and a n00b at scripting but am slowly learning from tutorials, I was wondering if anyone knew if there was a way to make a wall that only the player could walk through? I want to create safe zones for the player so the enemy can’t kill them, ANY ideas would be much appreciated thank you!

Layer based collision was created for this specific purpose: