Stealth and combat are one of the areas of 5e where there are actually a lot of grey areas in the rules. This is probably intentional to allow for different situations and give the dm to make judgement calls.
Hiding:
- You can’t hide from a creature that can see you clearly.
- If a creature becomes aware of your position you are no longer hidden.
- An invisible create can always try to hide.
Finding a hidden creature:
- In lightly obscured areas have disadvantage on Perception checks that rely on sight
- A creature suffers from the blinded condition when using vision to see in a heavily obscured area
Attacking:
- Attacking a target which can’t see or hear you gives you an advantage on your attack role. However you do not always get an advantage on attacks when hiding. You must meet the previous requirements.
- Attacking while hidden reveals your position regardless of if you hit or miss
- If you are hidden at the start of an encounter you surprise creatures unaware of you and they cannot move or take a action on their first turn.
Next, using these guidelines I will explore some possible scenarios for melee and ranged Attacks.