Call a function When a bool changes value?

I’m trying to call an animation/sound when a bool becomes true. How can I do that when it changes from false to true and not simply every frame that it is true?

Use properties : https://msdn.microsoft.com/en-us/library/aa288470(v=vs.71).aspx

private bool myBool ;

public bool MyBool
{
   get { return myBool ; }
   set
   {
       if( value == myBool )
           return ;

       myBool = value ;
       if( myBool )
       {
           // Play sound
       }    
   }    
}

this is really helpful, thank you @toddisarockstar!

here is a simple answer with an “if” statement if you don’t want to get into custom classes.

    bool mybool;
    bool checkit;
    
    void Update(){
    if(mybool!=checkit){
    checkit=mybool;

    print("my bool has changed to: "+ mybool);
   if(mybool==true){
//do stuff here
}
    }
    }