I'm trying to make a GUI countdown timer and I don't know where to start

Hello, I’m trying to make a GUI countdown timer and I don’t know where to start.
I know this is simple to many of you but I’m still learning to script so I’m trying to up my skills little by little. Please go easy on me, I’m new to scripting.

So basically the TextLable is going to count down from 1-10 then end… Where to do I start?

Here are some images.
Screenshot 2023-06-25 152419
Screenshot 2023-06-25 152450

local TextLabel = Script.Parent
local CurrentTime = 0

repeat
CurrentTime += 1
TextLabel.Text = CurrentTime
task.wait(1)
until CurrentTime >= 10

Here is an example how you might do it!

We have a Number variable; and Every second I add 1 to it. Then I display this change with TextLabel.Text = CurrentTime to show where the Variable is at! This repeats until up to 10!

1 Like

Local Script inside TextLabel
I took it you meant 10 to 1 …

local Duration = 10
local Label = script.Parent

local function updateCountdownLabel(countdown)
	Label.Text = tostring(countdown)
end

local function startCountdown()
	for i = Duration, 1, -1 do
		updateCountdownLabel(i)
		task.wait(1)
	end
    --Finished: do stuff here
	Label.Text = "Finished!"
end
--Start: countdown
startCountdown()
1 Like

What does tostring do? I’m just trying to understand the entire script.

It converts a Value into a string. Sometimes this is an issue other times it not. Like Boolen Values (true or false) are not string values (Letters). You can look and read more here ToString Documentation

1 Like

Converts a number value to a string value, as the text label here needs a string.

1 Like

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