Need help with the timer module

Hello, I need help with my module, I need each player to have a table with numbers, from which you can remove a certain value.

Currect code :

export type Timer = {
	removeAfter: (number, number, Frame) -> (),
}

local Timer : Timer = {}

function Timer.removeAfter(Minutes, Secounds, object)
	repeat
		if Secounds <= 0 then
			Minutes = Minutes - 1
			Secounds = 59
		else
			Secounds = Secounds - 1
		end
		if Secounds <= 9  then
			object.Text = tostring(Minutes)..":0"..tostring(Secounds)
		else
			object.Text = tostring(Minutes)..":"..tostring(Secounds)
		end
		wait(1)
	until Minutes <= 0 and Secounds <= 0
	
	return true
end

return Timer

The issue is that the provided module implements a countdown timer, but it does not address the requirement of managing a table of numbers for each player with the ability to remove specific values. I hope this’ll help you.

there’s an easier way to do this:

local function Timer(seconds)
    local minutes = math.floor(seconds / 60)
    local seconds_left = math.floor(seconds % 60)

    return string.format("%02d:%02d", minutes, seconds_left)
end

if you need something to happen when it ends just make an if statement that returns a different outcome, or set a function with a delay of the amount of seconds.

1 Like