You can make an Opportunity Attack when a creature that you can see leaves your reach using its action, its Bonus Action, its Reaction, or one of its speeds. To make the Opportunity Attack, take a Reaction to make one melee attack with a weapon or an Unarmed Strike against the provoking creature. The attack occurs right before the creature leaves your reach.
Disengage. If you take the Disengage action, your movement doesn’t provoke Opportunity Attacks for the rest of the current turn.
Reaction. A Reaction is a special action taken in response to a trigger defined in the Reaction’s description. You can take a Reaction on another creature’s turn, and if you take it on your turn, you can do so even if you also take an action, a Bonus Action, or both. Once you take a Reaction, you can’t take another one until the start of your next turn. The Opportunity Attack is a Reaction available to all creatures.
Reach. A creature has a reach of 5 feet unless a rule says otherwise.
RollQuest ships the D&D 2024 SRD as a content pack, on a 5e character sheet that does the maths - roll from the sheet and let the numbers work themselves out. Free to start.