Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

A GUI with a timer on it?

Asked by 10 years ago

I have a game for a friend. I'm helping. I want to know how to make a GUI with a timer. The timer is 60 all the way down to 0, but does nothing. After it is done, the GUI goes away. Help?

1 answer

Log in to vote
1
Answered by
Ekkoh 635 Moderation Voter
10 years ago

In this scenario it's probably best to use a numeric for loop, your script probably would look something like this-

local g = ... -- location of your GUI element (i.e. TextLabel, TextBox)

function countdown(time)
    g.Visible = true
    for i = time, 0, -1 do -- for i = start_value, end_value, increment do
        g.Text = i
        wait(1)
    end
    g.Visible = false -- disappear after 60s
end

countdown(60) -- call countdown(time) whenever you want to display a countdown
Ad

Answer this question