Instantiate an object with Random.range for a random position keeps spawning in the same place

The code seems okay with the random.range to instantiate and object in a random x , but when i start the game the gameobject keeps spawning in the same position … i searched for a solution for 3 hours but i didnt find any. i already used this code an other game and it works fine but here its not

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class obstacleSpawner : MonoBehaviour {
    public GameObject Obstacle;
    public float Cooldown = 3;
    public int X_max;
    public int X_min;

    private bool Allowspawning = true;
                                      
    void Start () {
        StartCoroutine("SpawnOBS"); 
    }

    // Update is called once per frame
    void Update()
    {

    }
 
    IEnumerator SpawnOBS()
    {
        while (Allowspawning)
        {
            Instantiate(Obstacle, new Vector3(Random.Range(X_min, X_max), 5.5f, 0f), Quaternion.identity);
            yield return new WaitForSeconds(Cooldown);
            yield return null;
        }
        yield return null;
    }
}

108674-26648008-1980733141961037-277429903-n.png

Did you assign any values to your

     public int X_max;
     public int X_min;

otherwise they are 0 and Random.Range will give you a value between 0 and 0 which is because of how Random.Range works with lower and upper border always 0.

I found the solution ! i had a free asset that contains that water . the water had a script contains a variable called noiseOffset , that variable used to change Random.seed or something dont know much about random.seed . after removing the variable and the line that has the variable and random.seed … everything worked fine !