Could use some help on making my runaway/chase/follow/patrol script cooperate with each other

Hello! I have a game where you are chased by a security guard but if you’ve bought the dog companion, the dog will chase away the security guard until he is far enough away that his code doesn’t make him want to follow you anymore. I have two scripts, one for the dog and one for the security guard. Here they are:
security guard: using System.Collections;using System.Collections.Generic;using UnityEngine; -
dog: using System.Collections;using System.Collections.Generic;using UnityEngine; -

My guess is my logic with all the bools is getting messed up and could use some other eyes on it. What’s happening now is the security guard never ‘notices’ the dog, he just follows the player and the dog follows him //It’s very janky and I’d love some help!

first, congrats to make a code so clean, is very nice to read seriously.

probably you already got the problem but, here we go

on guard script, you never set runAway as true, so, the guard dont know the fear xd

so edit the part of the follow algorithm, lines 29 to 37:

    if (follow)
        if(dist <= 1.05f)
        //set the distance to start runing
            follow = false;
            runAway = true;
            patrol = false;

also consider use (doggy.transform.position- cop.transform.position).sqrMagnitude this make computation fast, because you need calculate it on update function, but remember you need to set all the constats (the minimium distance to change behavior) squared, to keep the same state.