How can i make a spawn enemies function?

so im trying to make a wave system, this is probobly like a sequel to this post… but today i have a question that i cant answer myself, how can i make a spawn enemies function? so what im trying to achieve here is that i will have a table, that lists the number of enemy spawns per wave… then we spawn the enemies of the number on the table
ex:
Wave1 = 1
Wave2 = 10
(meaning 1 enemy will spawn in wave 1 and so on…)
then we start wave1 and we spawn 1 enemy
then start wave2 then spawn 10 enemies

now how can i make the script duplicate it to the according number of the waves? i already have a for loop, i just wonder how can i make this happen??

Thanks!!

2 Likes

why did you delete it? any adjustments needed tkobe made??

1 Like

After I posted I realize you already have the for loop so I felt like my post wouldn’t have been helpful

2 Likes

ooh ok, thanks so much!!! :smiley:

1 Like

function spawningenemies(numb)
for i = 1,numb,1 do

— put code here
—this code will run the same number of times as the number put when —you called the function

end
end

spawningenemies(10)—calling function —put number of enemies or
—times you want the code above to loop

3 Likes

ahh, that solves it!! i did a normal for loop tho… not that, i didnt think about that thanks so muchh!!

1 Like

You can create a table of certain parts in a folder in order to get a table of the CFrame of each part.

Create a folder where you place your meanies with different types with health depending on each

You can add a NumberValue parented to anywhere within the model of the creature to have a chance wether it would be spawned or not, and it has to be an instance NumberValue since it will have to be added on each wave.

You will need to create a function that loops on each meanie type and randomize their chance of spawning and increase it each wave, and then it loops on each spawn place, using math.floor you can place the number of meanies that will spawn for minimum in your wave (e.g: Wave1 = 1, Wave2 = 10) and add a small bonus for some monsters to spawn, so that way not every time you play you get the exact same number of creatures

And finally, you can Clone() them and SetPrimaryPartCFrame(spawnLocationPos) with their chance respectfully.

3 Likes

WOW, thanks so much for the explanation… that will help me A LOT just thanks so much!!!

2 Likes

This is just to add more variation, instead of manually making the googlies spawn in specified places, and to add variations to the meanies.

2 Likes

ahh, okay but still thanks so much!!

2 Likes