Level Generator porblem

Im making a game where the player has to climb up cubes, the Level generator generates 40 pieces at the start and I want it to add 20 every time the player reaches 20 more. So if hes at the 20 cubes 20 more spawn if hes at the 40 cubes 20 more spawn …

I have a function to spawn 20 cubes, I only need to make a script that checks if the player reached 20 cubes and then call the spawn function MakeLevel(); once.

allenallenallen is right in that we kinda need more than that…
but, are you jumping up on the y axis? how about if the player.transform.position is equal or greater than 20 you call MakeLevel() ?