This code says:
"As long as I'm still in trigger contact with something...
...if that thing is tagged 'Player', set move speed to zero
...otherwise (ie. if that thing is tagged anything else), set move speed to speed"
It looks like you mean that last clause to say "if I'm no longer in trigger contact..." but if we weren't in trigger contact anymore, OnTriggerStay
wouldn't even be called.
It looks like what you want is something more like:
bool isNearPlayer;
void OnTriggerEnter(Collider other) {
if(other.gameObject.CompareTag("Player"))
isNearPlayer = true;
}
void OnTriggerExit(Collider other) {
if(other.gameObject.CompareTag("Player"))
isNearPlayer = false;
}
This toggles a mode flag on & off when we enter & exit trigger range around the player. (Also note that using CompareTag is more efficient than comparing strings with ==)
Then you can use that mode flag in your FixedUpdate method:
if(isNearPlayer == false)
rb.AddRelativeForce...
(Even better, since you already have a reference to the player object, you can check its range directly, without waiting to detect trigger contact: isNearPlayer = (transform.position - friend.Position).sqrMagnitude < stopRange * stopRange);
)