Sounds like you wrote a bug… and that means… time to start debugging!
Are the relevant sections of code above running? Find out with Debug.Log()!
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.
I’ll start with the standard response. You have no Debug.Log statements so any number of conditions could be contributing to your problem. Is OnTriggerEnter being called, is the Capsule activeInHierarchy or not? Why the lowercase property name? Is the other.tag ever equal to “Barrier”?
Consider not naming your class barrier with a lowercase “b”. I’d recommend removing the extra blank lines (tidy code is better than messy code).
And finally if you are developing something “visual” it is often a good idea to develop the logic and to apply the visual after it is working. Meaning you don’t have to enable/disable objects to test the logic. When you see the conditions you expect in your Debug.Log statements you know the visual parts should work.
And one more than finally… your SetActive setting is always the opposite of the Capsul.activeInHierarchy I don’t think you need to test the condition just send as a parameter to the SetActive methods.