Running line once, from Update()

Hi,

I’m struggling with how to implement a line of code.

Basically I have a character follow the commands of my player, but only when the player is in range of the characters trigger.
but i’d like it so that when the player leaves the range a sound will play (each time he does it as well)

e.g. “hey come back” …

but when it comes to writing it i’m not sure where to put it that won’t run it like a million times a second from update.

this is what i’ve got so far (stripped down) -

void Update(){

		if (followPlayerBool == true) {
			followPlayer();
				}

		if (followPlayerBool == true && inCommandRange == false) {
			leftCommandRange();
		}
	}

	void leftCommandRange(){
//where I'd put the sound code
		print ("Come back!");
	}

You can use a bool to set this stuff

bool sayComeBack = false;

void Update(
{
    if (followPlayerBool == true)
    {
        followPlayer();

        if ( inCommandRange == false)
            leftCommandRange();
        else
            sayComeBack = true;
    }
}
 
void leftCommandRange()
{
//where I'd put the sound code
    if ( sayComeBack )
    {
        print ("Come back!");

        sayComeBack = false;
    }
}