The faulty cube will show up quite a few times throughout the game. One of the most confusing things to predict is when the faulty cube will be spawned. I originally had it that every 1000 cubes you spawn, a faulty cube will appear. But I changed it a lot and here's the simple version of what happens:
Each platform has a limit of cubes you spawn before you have to reset to spawn anymore cubes at that wall. The lower the limit of cubes, the higher frequency the faulty cubes spawn.
To tell you what is happening, every cube you spawn, the 'random faulty cube' dice is tossed. The script says that the range of the random faulty cube is the cube limit plus one.
Say you have a cube limit of 2, the random faulty cube range will be 3. That means there is 0.33% chance that out of the two cubes spawned, one will be a faulty cube (1-(2 divided by 3)).
So what if the cube limit is 29? The random range will be 30. That means there will be a 0.033 percent chance there will be a faulty cube spawned (1-(29 divided by 30)).
The chances get smaller the bigger the cube limit.