Help With Timer in Module

Help, I looking for a way to continue returning the countdown time until the timer ends.

Here is my script:

local module = {}

function convertTime(i: number)
	local minute = tostring(math.floor(i/60))
	local sec = math.floor(i%60)

	if sec < 10 then
		sec = "0".. tostring(math.floor(i%60))
	end

	return minute..":"..sec
end

function module:StartCountDown(Time: number)
	for i = Time, 1, -1  do
		local CountDown = convertTime(i)
		task.wait(1)
		return CountDown
	end
end

return module

any help is appreciated~

In

for i = Time, 1, -1  do
		local CountDown = convertTime(i)
		task.wait(1)
		return CountDown
	end

You return on the first instance of the loop, making it so it halts.

so how can i return it constantly

You can only return once.

You could try making an iterator function or directly changing the time value in the module.

Here’s what you could do (this is pretty complicated)

module:

return function(t)
	return function()
		t -= 1
		if t == 0 then return nil end
		return t, string.format("%02d:%02d",t/60,t%60)
	end
end

script:

time_itterator = require(script.Parent.Time)
for t, strep in time_itterator(10) do --t is for time, strep is for string repersentation
	task.wait(1)
	--stuff
end