# How can I make an Enemy Spawn system similar to Tower Warfare and Tower Defenders?

In my time of playing games I have grown to love Tower Defense Games, and that is only amplified when on Roblox there are a lot of different tower defense games. Two of my favorite tower defense games on Roblox are Kuzx and spacecr4zygamer’s Tower Warfare as well as lysandr’s Tower Defenders. These are two great games I highly enjoy playing with friend’s, and I have always wanted to make a tower defense game myself. So, recently I have started work towards making a tower defense game, and I would be lying if I said I didn’t take inspiration from these games in the process of making my game.

Anyways, enough background information aside, let’s get into the problem I am facing.
While I have a working wave system that spawns zombies, I feel like it could be reworked a little so it is made better. Now, my system is based off of this post:

I like the system, but I like the wave system in the two games I talked about above better. What I would like to achieve is finding a good way of spawning the different enemy types I have in my game in a pattern kind of like in Tower Warfare and Tower Defenders, having harder enemies more often than the weaker enemies in later waves. Currently to calculate the number of enemies to spawn per wave I have a local script with equations for each enemy type as well as conditions to check the wave number to see if a certain enemy type should spawn. If that condition is met then a remote event is fired with the number of each enemy for the wave. Then that is received by a server script with code similar to the post I linked.

My main question is what is the best plan of action for making a good enemy spawning system, as I would just like some feedback since I think I could use a better system.

2 Likes

The spawning procedure I use for Tower Defenders is a `for loop` that goes up to the x amount of waves I want, in TDs case it’s 37. It calls the corresponding global variable (which in this case is a function) that is predetermined to spawn specific enemies.

Each round is custom engineered and does it’s own thing

#### A global variable function that’s called

Whether this is the best method or not, I’m not sure. It all depends on what you want to do for your specific game. This worked best for what I wanted for Tower Defenders, and I can’t see myself changing it in the future.

2 Likes

When you said each round is custom engineered do you mean, for example, every round would have a separate function for spawning enemies? I was thinking about doing something like that but I wasn’t sure if that was an efficient method for spawning the enemies.

1 Like

Yes you are correct. Each round has it’s own separate function. There is a separate script/module for all of the functions of the rounds.

As you can see I utilize the `_G` global variable to communicate data & calls across scripts.

I think any which way you design it there will be a wall of code somewhere. But again, this happens to work for me so I stick with it.

1 Like

Alright. I think that is what I am going to plan on doing then. Thanks a ton for the help!

Also as a side note, I am looking forward to the future updates on Tower Defenders, it’s one of the best games you could play on Roblox at the moment in my opinion.

1 Like