Opioids attach to proteins called opioid receptors on nerve cells in the brain, spinal cord, gut, and other parts of the body. When this happens, the opioids block pain messages sent from the body through the spinal cord to the brain.