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?
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!
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()
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