How can I add the enemies within an enemy cycle inside of a module script?

Hello developers.

I’m making a 2D, Tower Defense game and starting to work on the enemy cycle for the first level in my game. I’ve have an enemy cycle within a module script which is located inside of a script called “Battler_Handler” located in ServerScriptService which is primarily used to control the Battler’s movement and what team they are on.

As the title says, I don’t know how I can get the enemies within the enemy cycle to appear in-game. This is the enemy cycle if you are wondering (Inside of the module script):

StageModule.EnemyCycle = {
	[1] = {
		["EnemyName"] = "Dummy",
		["Amount"] = 2,
		["Cooldown between Spawns"] = 1

Anyway, how can I achieve this? Also, keep in mind that I’ll be adding more enemies into the cycle whenever the first enemy cycle is completed.

1 Like

just to make sure, you’re trying to make so that two dummies are made every 1 seconds and you want them to be spawned into the workspace? as a rig?

1 Like

Yeah, something like that. I’m also adding to add more enemies once the first level enemy cycle is done.


ok this is just an example of how you can do it:

right here is the main “Battle_Handler” script. it has a child rig named “EasyEnemy” underneath it (assuming you are going to make more enemies such as harder ones you can change the name or make a folder under the script instead with all of the enemy models, this lets you change the models color and stuff if you want to.)

anyways, like i said here’s the BattleHandler script:

local ServerStorage = game:GetService("ServerStorage")
local ModuleScripts = ServerStorage:WaitForChild("ModuleScripts")
local StageModule = require(ModuleScripts:WaitForChild("StageModule"))

local easyEnemyModel = script:WaitForChild("EasyEnemy")
local spawnPos =,50,0)

while true do
	for i = 1, StageModule.EnemyCycle.EasyEnemy.Amount do
		local easyEnemyModelClone = easyEnemyModel:Clone()
		easyEnemyModelClone:WaitForChild("Torso").Anchored = true
		easyEnemyModelClone:WaitForChild("Torso").Position = spawnPos
		easyEnemyModelClone.Parent = workspace
		spawnPos +=,0,0)
			easyEnemyModelClone:WaitForChild("Torso").Anchored = false
	spawnPos +=,0,0)

The spacing and anchoring and all that is just to display that it is working as intended i hope. here is the revised module script as well:

local StageModule = {}

StageModule.EnemyCycle = {
	["EasyEnemy"] = {
		["EnemyName"] = "Dummy",
		["Amount"] = 2,
		["Cooldown"] = 1

return StageModule

if you want to you can make more values inside the module like health, speed, etc. stuff like that. also, here is the structure that i used when testing (if you would like to test this yourself):


i hope this is mostly what you were looking for!