How do you spawn a gameobject based on last object in array and limit that within a range?

My current scripts to spawn
`public Transform Spawner;
public GameObject chunks;

Instantiate (chunks[spawnPointIndex], Spawner.position + new Vector3(chunks[spawnPointIndex - 1].transform.position.x + Random.Range(-5f, 5f),Random.Range(10f, 10f),100), Spawner.rotation);`

What I want to do is spawn “chunks” based on the last chunk spawned so that the offset from the last spawned chunk and the current chunk is at best 5. All that within the range of -20 to 20.

fixed it by making a float, using that for one coordinate, change it after it being used with random.range and than clamping it with an if statement.