Changing Second Material

Hi! I have a object with 2 materials on it, and I want to change the second material via code.
This is the code I’m using:

public class ChangeColorGreen : MonoBehaviour {
	public PlayerScript playerScript;
	public Material[] materials;
	public Renderer rend;

	void Start () {
	
	}

	void Update () {
		if (playerScript.isGreen == true) {
			rend.sharedMaterials[1] = materials[0];
		}
	}
}

When I attempt to change the second material, absolutely nothing happens:

But when I change the code to

rend.materials[1] = materials[0];

This happens:

But I can change the first element perfectly fine: http://i.imgur.com/n5kHuLf.png?1
(changed to imgur becuase the site stopped me from uploading pictures)

So does anyone have an insight on this? Thanks!

I have managed to figure this out by myself, changed the code to

rend.materials [1].color = materials [0].color;

and it works perfectly fine. Use

rend.sharedMaterials[1].color = materials [0].color;

if you want the color change to stay permanently.