Hi, welcome. :>
Is it the case that the for loop crashes because it's trying to remove too many seedlings?
Ie it loops 10 times, removing one seedling each time, but there were only 5 seedlings to begin with so it crashes when it tries to remove the 6th?
If that's the case, try something like this:
local i = 0
for i = 0, numToRemove do
if asteroid:GetNumSeedlings(1) ~= 0 then
You're saying "ok Mr Loop, I only want you to remove seedlings IF the number of Player 1 seedlings present at the asteroid is not 0."
So in the example above, after all 5 seedlings have been removed, the number of seedlings would be 0, so the remove command would not be triggered again. The rest of the loop iterations would finish harmlessly.