Hello.
When you create a new ball, you put a counter variable to know how many balls are in play, on the PF at each moment. We will call this variable BIP.
This variable is the one that carries out internal control in the ball code over the PF or that are in play, BIP of Ball In Play.
Dim BIP
BIP = 0 'We initialize the value to zero because at this time, we have not yet created any balls on the PF.
Creating a new ball (for play, or for a multiball, for example) causes you to add +1 to the ball counter control variable:
Kicker_In.CreateBall
BIP = BIP + 1
Then you throw the ball in any direction you want, including up, to continue the game. For example, to release the ball to the right of the kicker:
Kicker_In.Kick 90.7
When the ball falls to a kicker that destroys it (Drain, Tunnel Hole, etc.) that is, when the ball physically leaves the field of play (not by placing itself on another platform or elevated mini PF), Remember: use it if the ball physically leaves the PF, if you pretend to go under the PF to exit or reappear somewhere else, or if you are going to teleport the ball in some "disappear and reappear" way.
So you use:
Kicker_Out.DestroyBall
BIP = BIP - 1
When you respawn, you add +1 again, that is:
Kicker_In.CreateBall
BIP = BIP + 1
If it is the same hole in the PF that it respawns through, you use its corresponding name for that:
Kicker_Out.CreateBall
BIP = BIP + 1
This way, you will know when there are no more balls left on the PF. You will know the event that causes balls to be subtracted or added according to your script. For example, Drain_Hit will trigger a ball loss, so if you have another variable with the number of balls remaining in the game, you will subtract -1 from that value, in addition to subtracting one ball from the variable that controls balls over the PF or that are at stake, BIP.
If it is a multiball, you will know that one of the multiball balls has been lost, so you will have to decide whether to create a new one or not, depending on the maximum number of balls you want to have at the same time on the PF.
So, if you know that BIP = 0, it means that the ball has disappeared at some point that is designed to destroy balls, and if, as you say, your script creates a lost ball if the sensors you installed do not detect anything, it is the same as checking in in "If BIP = 0 Then ..."
If it got stuck somewhere on the PF, but has not been deleted from the game, BIP must have a value of at least 1 ball over PF, that is, there is a ball in play even if the sensors you placed do not detect a collision in them.
I don't know if I have helped you clarify ideas, but in most scripts I have read a similar method is usually used to keep track of balls in play.
Greetings.

EpeC.