flash is a type but your copying it as an entity using CopyEntity(flash) your also doing the same with shot.
That's not the reason. In your loop you're re-using the variable s for different data types ( shot and flash ) which cannot be done inside the same function.
Try using f.flash for all the flash stuff - I'm pretty sure that will work.
Stevie