2d beat em up clamp player when leaving another player

I have been all over the place and its like no one has an swer for this. but im trying to make a beatem up and im trying to make a part where if the player is leaving another player behind (if they go in opposite directions or one isnt moving) the player cant leave or move the camera i thried clamping but it just gets janky (children rig is the player and group x is the virtual cam)

    public void Areana(Transform player)
    {
      
      
        childrenRig = player.GetComponentInChildren<Rigidbody>();
        float childrenRigx = childrenRig.transform.position.x;
        float groupX = virtualCam.transform.position.x;
        childrenRig.position = new Vector3 (
             Mathf.Clamp (childrenRigx, groupX -5.436225f, 0.460665f - (groupX) ),
            childrenRig.position.y,
            childrenRig.position.z);

i tried to clamp it around the players current location and the min and max is bassed off the changing x value of the virtual camera. it just gets all wrong is there a better way im bout to just give up and us box colliders as borders.

Besides the really strange naming I guess the approach make sense. The Clamp looks suspicious though. I dont really know what are those magic numbers but it seems to me that with increasing groupX value the min value gets quickly larger then the max value. If the game is side scroller then the groupX value will increase and so it breaks.

Example:

groupX = 0, => min = -5.4, max = 0.4 (min < max)

groupX = 10, => min = 6.6, max = -9.6 (min > max)