In this tutorial i added a script to open the door when an fps player enters a trigger.
Unity sliding door with switch script.
How to make automatic doors in unity new.
Below is a script to make a sliding door instead of a regular one suitable for sci fi levels and futuristic doors.
All of your doors open because you re not actually checking whether or not the hit object from your raycast is actually the door object your script is holding a reference to.
They re a little rougher than my usual ones but here s one of the first few a quick overview of making automated doors for your games.
Imtiaj touches on this briefly but string compares on game objects are a bad idea and does not limit yourself to one object as many game objects an have the same name.