Time Counter Script

Hello, Im currently trying to make a hour, minute and a second time counter that will display on a certain GUI object (in my case - text label).I have n o idea how to do that tho. I don’t need hour counter above 9, it should only have hours like 1,2,3 … 9.

Here’s a script that will count minutes and hours since it was started.

--!strict
local text_label: TextLabel = script.Parent

local minutes: number = 0
local hours: number = 0

while task.wait(60) do
    -- sixty seconds passed, add a minute
    minutes += 1
    if minutes > 60 then
        -- sixty minutes means an hour passed, reset minutes
        hours += 1
        minutes = 0
    end

    -- convert our numbers into text with a colon inbetween
    text_label.Text = string.format("%d:%d", hours, minutes)
end
1 Like

Okay i figured it out, thank you for helping!

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