Training Hub Remaining Minutes

Hi Cookie Tech Community!

I’m making a training hub UI and I want to add a remaining minutes text. Like this: “:alarm_clock: Begins in X minutes”.

I made a script but it gives -402 minutes.

local function calculateRemainingMinutes(h, m)
	local currentTime = os.time()
	local endTime = os.time({year = os.date("%Y"), month = os.date("%m"), day = os.date("%d"), hour = h, min = s, sec = 0})
	local remainingSeconds = endTime - currentTime
	local remainingMinutes = math.floor(remainingSeconds / 60)

	return remainingMinutes
end

and I’m calling it like this:

training.Remaining.Text = "⏰ Begins in ".. calculateRemainingMinutes(session.Hours, session.Minutes) .." minutes"

Can someone help how to fix that? Thanks!

If you have a working training hub, please dm me on DC. @levikeauthority

currentTime - endTime?

Let me change the script

kép

It gives these variables

print remainingSeconds quickly

I solved it. Thanks for assistance.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.