Generate cubes in 5 areas

i have a plane surface with 5 vector3 for a position on the surface for a cube.When the game starts the cube move towards me with a randomly generated position of the 5 vector 3’s. i want that when the cube’s position is between 2 points on the x surface , i want the cube to Instanciate and again pick one of the 5 positions and again start moving towards me and this should continue in a cycle.

This is the code i am using to pick one of the 5 positions.

public Vector3 Gen(Vector3 sam)
{
    int posStart = Random.Range(0, 5);
    if (posStart == 0)
    {

        sam = one;
    }
    else if (posStart == 1)
    {

        sam = two;
    }
    else if (posStart == 2)
    {

        sam = three;
    }
    else if (posStart == 3)
    {
        sam = four;
    }
    else if (posStart == 4)
    {
        sam = five;
    }
    return sam;
}

i can move the cube, no problem there

This is the code for instanciation

if (enemy.transform.position.x >= 1.49 && enemy.transform.position.x <= 1.5)
{
Instantiate(enemy);

    }

This works some times and fails the other times.
Some times it does this process 2-4 times and then it just stops generating

Any help would definitely be appreciated.
Thanks!!

Your cube’s speed may be too fast for a range of 0.1 units. You’re checking if it’s position is between 1.49 and 1.50. It’s a very small range.

If your cube moves too fast then it’s position may go from 1.48 to 1.51. It all depends on the speed.

Other than that, your code looks completely fine to me, but although we’re only seeing a small portion of it so there may be a problem elsewhere.