How to check the value being iterated

So Im currently making a td game and Im making a functional wave system. I have a module called “Waves” which is basically a dictionary of all waves in the system:

Waves Module:

local WaveHandler = {}

WaveHandler.Easy = {
	["Wave1"] = {
		["Max Time"] = 10,
		["Wave Structure"] = {
			[9] = "Mom",
			[7] = "Mom",
			[5] = "Mom",
			[3] = "Mom"
		}
	}
}

return WaveHandler

and in a server script we iterate this dictionary and get all the wave info

function startWave()
	for index, wave in pairs(WaveHandlerModule.Easy) do
		TimeLeft.Value = WaveHandlerModule.Easy["Wave" .. CurrentWave]["Max Time"]
		coroutine.resume(SpawnTimer)
		for _, obj in pairs(WaveHandlerModule.Easy["Wave" .. CurrentWave]) do

			if not (obj == 10) then
				repeat task.wait() until enemyFolder:WaitForChild(obj[TimeLeft.Value])
				print(obj[TimeLeft.Value])
				print(TimeLeft.Value)
				local spawnEnemy = coroutine.create(function()
					EnemyHandlerModule.SpawnEnemy(enemyFolder:FindFirstChild(obj[TimeLeft.Value]))
				end)
				coroutine.resume(spawnEnemy)
			end
			
		end
	end
end

but the problem is I do not know how to check if our “obj” is at [“Max Time”], and iterating directly trough the wave layout leaves out these part

image

and returns only “Mom”

I’m not sure I understand what you’re trying to do here.

Wouldn’t it be easier to just iterate over the wave data table instead of all the fields in Wave1 ?

as I have said, by iterating trough the “Wave Structure” itself it leaves out this area
image
which is needed so that the enemies can spawn since it uses the timer to spawn these enemies

Can’t you check the key of the iteration?

for waveNumberThing, waveValue in pairs(waveStructure) do
    print(waveNumberThing)
end

oh ye ty that can be a solution :sweat_smile: Ill try it out rn