Change variable in another script by calling function

I’m using a script on object A to call a function on another object B which has a variable “play”.

The script on object A executes this:

var noteHandlerScript : noteHandler = noteHandlerPrefab.GetComponent(noteHandler);

And the StartPlaying() function in the script on object B sets the variable “play” to true.

internal var play : boolean = false;
function StartPlaying(){
      play = true;
      print ("Play is: " + play);

However, when I check the variable play in the Update() of the object B, it always says false. Why isn’t play getting set to true? The print statement in StartPlaying() function says play is true.

You appear to be calling the method on the prefab and not the instance that you created from it. This isn’t changing anything in the game (but would change the next item you instantiated from the prefab!).