Since StageModule.EnemyCycle is a dictionary, you can use simply index the key where you want to add a new value.
Here is how you could implement it:
Solution 1: Dictionary Version
Script accessing the ModuleScript
local StageModule = require(workspace:WaitForChild("StageModule")) --Change this to where the ModuleScript actually is
local newEnemy = {
["EnemyName"] = "Dummy2",
["Amount"] = 3,
["Cooldown between Spawns"] = 1.5
}
--Adding a new enemy to StageModule.EnemyCycle
StageModule.EnemyCycle[2] = newEnemy
I would recommend making StageModule.EnemyCycle a table instead of a dictionary. From what I can see, you can achieve the same result with StageModule.EnemyCycle as a table instead of a dictionary, while making it much easier (in my opinion) to add a new element at the end of a table than at the end of a dictionary.
Explaination
Dictionary Version (Current Version)
StageModule.EnemyCycle = {
[1] = {
["EnemyName"] = "Dummy",
["Amount"] = 2,
["Cooldown between Spawns"] = 1
}
}
Table Version
StageModule.EnemyCycle = {
{
["EnemyName"] = "Dummy",
["Amount"] = 2,
["Cooldown between Spawns"] = 1
}
}
If you plan to change EnemyCycle to a table instead of a dictionary, you can use table.insert(table, value) instead, which inserts value at the end of table. You can implement it like this:
Solution 2: Table Version
ModuleScript
local StageModule = {}
StageModule.EnemyCycle = {
{
["EnemyName"] = "Dummy",
["Amount"] = 2,
["Cooldown between Spawns"] = 1
}
}
return StageModule
Script accessing the ModuleScript
local StageModule = require(workspace:WaitForChild("StageModule")) --Change to where the ModuleScript is actually stored
local newEnemy = {
["EnemyName"] = "Dummy2",
["Amount"] = 3,
["Cooldown between Spawns"] = 1.5
}
--Adding the new enemy
table.insert(StageModule.EnemyCycle, newEnemy)