From Bulbapedia, the community-driven Pokémon encyclopedia.
The Toxic sure-hit glitch is a glitch in the Generation VI, VII, and VIII core series games.
It first appeared in Pokémon X and Y and appeared in all subsequent core series games until Pokémon Sword and Shield. It occurs in Pokémon Sword and Shield versions 1.0.0 to 1.3.0, but was fixed in version 1.3.1.
If a Poison-type Pokémon uses Toxic, any moves it uses for the rest of the turn will be guaranteed to hit, even if a target is in the semi-invulnerable turn of a move (such as Fly or Dig).
This is relevant in cases where a Pokémon uses multiple moves in a single turn, such as due to Instruct, Dancer, or Magic Bounce. It is also relevant for Future Sight and Doom Desire.
For example, consider a Poison-type Pokémon that had used Toxic the previous turn, but selected Horn Drill this turn. If it is affected by Instruct before it makes its regular move to force it to use Toxic, when it performs the selected Horn Drill later that turn, that Horn Drill will be guaranteed to hit.
From Generation VI onward, if a Poison-type Pokémon uses Toxic, that move will always hit, even if the target is in the semi-invulnerable turn of a move (such as Fly or Dig). To achieve this, a temporary flag is set on the Pokémon for the rest of the turn, that ensures its moves will always hit. Consequently, if the Pokémon uses additional moves after Toxic in the same turn, those moves will never miss either.
This flag is set during the execution of Toxic, even if it is used via Instruct or Magic Bounce. This flag will be set even if Toxic goes on to fail for reasons such as the target already being poisoned, being a Steel-type, or being protected by Safeguard; however, it will not be set if Toxic is prevented from being used by Disable, Taunt, or Imprison.
This flag cannot be passed via Baton Pass and disappears if the Pokémon switches out.
It is currently unknown how this glitch was fixed in Pokémon Sword and Shield version 1.3.1.