Opioids act by attaching to specific proteins called opioid receptors, which are found in the brain, spinal cord, gastrointestinal tract, and other organs in the body. When these drugs attach to their receptors, they reduce the perception of pain.