When attempting to hide, there are 4 simple rules to remember.

  1. If someone can see you, you can't attempt to hide from them
  2. Someone doesn't see you when they're not looking at you
  3. Once hidden, you can be detected via sight, hearing, or both, so don't be seen or heard. If their perception check or passive perception is higher than your stealth roll, they detect you
  4. You can hide in plain sight, given a moment of being unseen or unattended and an appropriate concealment strategy

If you are hidden, or when someone can't see you, you have advantage on attack rolls against them, and they have disadvantage on attack rolls against you. If you make an attack while hidden, regardless of whether it hits or misses, you are no longer hidden.