The vaccine works by generating antibodies that bind to the target opioid to prevent it from reaching the brain. If the opioid reaches the brain, it creates a euphoric feeling but can stop signals that control breathing.
https://www.washingtontimes.com/news/2021/sep/23/first-opioid-vaccines-clinical-trials-us/