Coroutine help?

		local c = coroutine.create(function()
			while task.wait(0.05) do
				SpawnRainingBomb()
			end
		end)
		
		coroutine.resume(c)
		task.wait(DInfo.Time)
		coroutine.yield()
		c = nil
		print('Disaster Over')

I have this inside a function

full function
function module.StartDisaster(disasterID, DInfo)
	if disasterID == 1 then
		print('Raining Bombs')
		
		local c = coroutine.create(function()
			while task.wait(0.05) do
				SpawnRainingBomb()
			end
		end)
		
		coroutine.resume(c)
		task.wait(DInfo.Time)
		coroutine.yield()
		c = nil
		print('Disaster Over')
		
	end
end

but it never ends and i don’t know why
can someone help?? thank you
It also yields where the function is being ran

i have never used coroutine before

i partically fixed it by removing the coroutine.yield() now it continues in the function after task.wait(DInfo.Time) which i dont want - i want it to continue as soon as the function is ran

and the bombs still rain forever

update i fixed it myself !!

i did some math and decided not to use that math because i cant do math and then i just used random numbers that sounded right

coroutine.wrap(function()
			local c = coroutine.create(function()
				for i = 300, 0, -1 do
					SpawnRainingBomb()
					wait(0.01)
				end
			end)

			coroutine.resume(c)

			wait(DInfo.Time)
	
			print('Disaster Over')
		end)()

instead of a while true loop, i used a for i loop