Invalid 'for' limit (number expected, got nil)

I am trying to make a tower defence game and have a wave system Implemented, but When I run the game and it gets to wave eight I get the error " invalid ‘for’ limit (number expected, got nil) "

I have tried changing the number of waves and what spawns when in the was, but still have this issue. I check on the dev forum but haven’t seen any solutions yet.
Does anyone know what the problem is?

If any more info is needed just ask. Thanks!

1 Like

can you show us the line which errors


Line 29


It’s in a local script which I use to Spawn the mobs.

Quantity is nil. Where do you call the function?

Use (quantity or 0) rather then just quantity

1 Like

Thanks that really helps.
Do you know the reason you need to add a 0?

If quantity is nil then 0 is used as the end for the numeric for loop instead.