I have an object that is made up of multiple pieces and I am trying to change the opacity of all of them at the same time with one GUI slider. I use the following script successfully on one object, but when I attach it to more than one it only works on one object at a time.
EDIT: Presuming all your GameObjects are using the SAME material:
Use Renderer.sharedMaterial instead. All objects using this material will be permanently affected, hence I strongly recommend creating a new dedicated material before playing with this method.
If I understand your problem correctly, this is probably the easiest way to achieve your goal, if you understand the risks involved.