Need help to finde a logic error in my spawner script regarting the random position in 2D

A have a problem with the random position of spawns in my spawner script. I didn’t find a good solution online but i haven’t looked long, so i thought of my own version:
I need to spawn enemies with Instantiate() on the plain. The position needs to be out of bounderies but not to far to save some cpu. So there is basicly an inner box in the middle that is not allowed and an outer box, between them thay should spawn. That was the goal.
Here is the code with notes:

void Start()
    {
        innerBorderX = GameObject.Find("BodenT").GetComponent<BackgroundScroller>().rightEdge;  //16
        innerBorderY = GameObject.Find("BodenT").GetComponent<BackgroundScroller>().topEdge; //20
        outerBorderX = innerBorderX + 10;
        outerBorderY = innerBorderY + 10;
       
    }
void SpawnEnemy()                                                                                   //The random Selection of enemies needs to be implemented
    {                                                                                                   //Instantiate water Elemental
        GameObject a = Instantiate(waterElemental) as GameObject;
        if (Random.Range(0, 1) == 1){                                                                    //rolling dice for priority 1 = horizontal 0 = vertical
            randomX = Random.Range(-outerBorderX * 100, outerBorderX * 100) / 100;                       //setting an X value from full span
            if(randomX < -innerBorderX|| randomX > innerBorderX)                                //when X is out of Bounderies, Y can have full span
            {
                randomY = Random.Range(-outerBorderY * 100, outerBorderY * 100) / 100;                   //setting an Y value from full span
            }
            else                                                                                         //when X is in the Bounderies, Y needs to be top or Bottom span
            {
                if (Random.Range(0, 1) == 1)                                                             //rolling dice for priority 1 = top, 0 = bottom
                {
                    randomY = Random.Range(innerBorderY * 100, outerBorderY * 100) / 100;                //setting Y value from top span
                }
                else
                {
                    randomY = Random.Range(-outerBorderY * 100, -innerBorderY * 100) / 100;              //setting Y value from bottom span
                }
            }
        }                                                                 //RandomX und RandomY werden ausgewertet
        else
        {                                                                                                //if vertical has priority
            randomY = Random.Range(-outerBorderY * 100, outerBorderY * 100) / 100;                       //setting Y value from full span
            if(randomY < -innerBorderY|| randomY > innerBorderY)                                //wenn an Y is out of Bounderies, X can have full span
            {
                randomX = Random.Range(-outerBorderX * 100, outerBorderX * 100) / 100;                   //setting an X value from full span
            }
            else
            {                                                                                            //when Y is in the Bounderies, X needs to be left or right span
                if (Random.Range(0, 1) == 1){                                                            //rolling dice for priority 1 = left, 0 = right
                    randomX = Random.Range(-outerBorderX * 100, -innerBorderX * 100) / 100;              //setting an X value from left span
                }
                else
                {
                    randomX = Random.Range(innerBorderX * 100, outerBorderX * 100) / 100;                //setting an X value from right span
                }
            }
        }
        a.transform.position = new Vector2(randomX, randomY);                                           //setting the position of "a" to random out of Bounderies
    }

what happens here is that the enemies spawn in a rectangle but the left edge doesn’t spawn anything… i can’t see why this happens, please help.

Here is how you can get to the bottom of it and find out what is actually happening.

What is often happening in these cases is one of the following:

  • the code you think is executing is not actually executing at all
  • the code is executing far EARLIER or LATER than you think
  • the code is executing far LESS OFTEN than you think
  • the code is executing far MORE OFTEN than you think
  • the code is executing on another GameObject than you think it is
  • you’re getting an error or warning and you haven’t noticed it in the console window

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run? what order does it run in?
  • what are the values of the variables involved? Are they initialized? Are the values reasonable?
  • are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

Knowing this information will help you reason about the behavior you are seeing.

If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

You could also just display various important quantities in UI Text elements to watch them change as you play the game.

If you are running a mobile device you can also view the console output. Google for how on your particular mobile target.

Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

https://discussions.unity.com/t/839300/3

You must find a way to get the information you need in order to reason about what the problem is.