Okay my question is if you poison your opponents active pokemon when they have 10 hp left what comes first inbetween the turn poisin or the healing ability?
All effects that take place between turns are calculated before checking for KOs. As such, the Poison would deal 10 damage (reducing HP to 0), then (in the above example) Royal Heal would heal 10 damage (increasing HP to 10). Then the game would check for knockouts. As the damage was healed, the Pokemon is not knocked out.
Referencing:
605. Between-Turns Phase
605.1 Between turns, the following things happen in order.
605.1a Special Conditions on Pokémon that need between-turns processing are resolved. If multiple Special Conditions affect a single Pokémon, resolve them in the following order: Poisoned, Burned, Asleep, Paralyzed.
605.1b Effects that trigger between turns and are dependent on a between-turns check are triggered.
605.2 If an effect triggers between turns that is not dependent on a between-turns check, that effect can be handled at any time during the above steps. The owner chooses when to use the effect.
605.3 Once all between-turns actions are processed, between-action checks are performed (304). The next player then begins their turn.
304. Between-Action Checks
304.1 A series of checks occurs after the resolution of each turn action (602.1) and at the end of each game phase (600.1).
304.2 Between-action checks are performed in a series of waves. In each wave, the following checks are made simultaneously.
304.2a Any waiting triggered modifiers are resolved.
304.2b All Pokémon that have accumulated damage equal to or greater than their HP are Knocked Out (305.2).
304.2c If a player no longer has an Active Pokémon for any reason, that player moves one of their Benched Pokémon into the Active position.
304.3 If a wave triggers an effect, another wave is performed. These waves continue until no further actions take place. The combined actions of all waves are considered to occur simultaneously.
304.4 Once all waves of checks are complete, the game state is then checked to see if any player has met a win condition (606.1).