Add component: Script

Hi all,

I’d like to add a script to a gameObject, depending on its name.
Here is my code:

 var power : String;
 var scriptToAdd : MonoBehaviour;
 function Start ()  
  power = PlayerPrefs.GetString(;
  scriptToAdd = Resources.Load("powers/power_"+power+".js");

I checked the path, no typo, the script is here, but “scriptToAdd” remains empty

“extensions must be omitted”

(Can scripts even be loaded from resource files? This will obviously fail on iOS since the scripts are converted into machine code during the build process.)