Hello developers.
I’ve created a module script which stores a level’s information such as rewards and inside of the module script is an enemy cycle which looks like this:
StageModule.EnemyCycle = {
[1] = {
["EnemyName"] = "Dummy",
["Amount"] = 2,
["Cooldown between Spawns"] = 1,
["Delay before switching to next Enemy"] = 5
}
}
As the title says, I’m trying to find a way to get the information from this dictionary (Such as the enemy’s name, the amount the enemy spawns, the cooldown between spawns and etc.). I’d tried attempting this although I keep getting bombarded by a “Invalid ‘for’ limit (number expected, got nil)” Error. This is the attempted script:
for i=0, LevelList.EnemyCycle["Amount"] do
local getEntity = RP.Enemies:FindFirstChild(LevelList.EnemyCycle["EnemyName"])
if getEntity then
local existingBattler = getEntity:Clone()
--Positioning
existingBattler.Parent = workspace.ExistingEntities
existingBattler:WaitForChild("HumanoidRootPart").CFrame = workspace.dsdaDDSADSadsasdasdasda.CFrame + Vector3.new(0, 3, 0)
--Team
existingBattler:AddTag("EnemyTag")
for _, bodypart in pairs(existingBattler:GetChildren()) do
if bodypart:IsA("BasePart") then
bodypart.CollisionGroup = "NPCs"
end
end
else
warn("ENTITY DOESN'T EXIST!")
end
task.wait(LevelList.EnemyCycle["Cooldown between Spawns"])
end