Instances too often

Godot Version 4.2.2

Question

I am attempting to make an obstacle in my game that uses a random number generator to decide when to instance it but often they are instancing in each other or there are large gaps between how could I fix this

For solving your problem, I need more information, can you mention the codes?

func _process(delta):
var spawnchance = randi_range(0,120)
var new_car = car.instantiate(0)
if spawnchance == 3:
add_child(new_car)

If you want a fixed gap then define a variable offset = 3, if you want random then do like randi_range(3, 5), then define last_pos = 0, next:

var new_car = car.instantiate()
new_car.position.y = last_pos
last_pos += offset
#you can randomize the offset if it is random
add_child(new_car)

Then tell me if its working?