BCE0053: Property 'UnityEngine.Component.light' is read only.

Hello, I’ll make it short. Why am I getting this error :

BCE0053: Property ‘UnityEngine.Component.light’ is read only.

This is my code :

var sun : Light;
var enableShadows : boolean = true;

function Start()
{
enableShadows = true;
    if(enableShadows == true)
    {
        sun.light = LightShadows.Hard;
    }
}

This is just a small part of my code, but the other part doesn’t have anything to do with this one.

Thank you.

Correct this:

sun.light = LightShadows.Hard;

to this:

sun.light.shadows = LightShadows.Hard;