[RPG] When you cast invisibility on your turn, and walk away from 2 enemies, do they get an attack of opportunity

dnd-5einvisibilityline-of-sightopportunity-attack

When a PC is in melee with a creature, casts the basic invisibility spell, and leaves melee, does an NPC get an attack of opportunity?

Best Answer

No, they don't get opportunity attacks.

From PHB, page 195:

You can make an opportunity attack when a hostile creature that you can see moves out of your reach.