How to change guitext alpha value without error cs1612?

I get this error while trying to change the alpha value of a guitext:
“Assets/FloatingText.cs(47,34): error CS1612: Cannot modify a value type return value of `UnityEngine.Material.color’. Consider storing the value in a temporary variable”

I did a ton of googling around, and no matter how I try to adapt the things I found I just can’t get it working. The example script this is based on is unfortunately in Javascript, which apparently handles the thing that causes this error a bit different.

public class FloatingText : MonoBehaviour {
	private float speed = 0.03f;
	private float alpha;
	public float guiTime = 5f;
	private float duration = 1.5f;

	void Start()
		guiText.material.color =;
		alpha = 1f;
	void Update()
		transform.Translate(new Vector3(0f, 2f, 0f) * (speed * Time.deltaTime));
		//alpha = guiText.material.color.a; //Tried setting alpha into a temp variable but ain't working
		alpha -= Time.deltaTime/duration; 
		guiText.material.color.a = alpha;

	IEnumerator GuiDisplayTimer()
        yield return new WaitForSeconds(guiTime);



It must be a very simple thing to do, but every place that advices how to get around this error does it in a way that just seems totally incomprehensible. I have tried so many things with this it’s really frustrating right now. Here’s the script I have based this on : attack damage scrolling - Unity Answers

Thanks in advance.

As the error says, assign the the whole Color, not one component.

var c = .....color;
c.a = alpha;
.....color = c;

Or use JavaScript which handles these things for you.