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

how can I make a Screen GUI countdown? (Read desc. to find out what I talking about)

Asked by 7 years ago
Edited 6 years ago

Like in Mad Games when a round starting it said "Intermission 30" then 30 seconds later "Teleporting Players" how do I make it countdown and when it reached 0 its make it said "Teleporting Players" can someone make/copy a script and help me out? Like make it countdown to 0 and when it reached 0 then it make the text said "Teleporting Players!"

If you help Thanks! If you closed mine "Wow.... like some or a lot of game have this! How is this not work? It's a script it making the text from the ScreenGUI count down!"``

So I did

for i=30,1,-1 do
wait(1)
gui.Text = "Intermission: 30" "..i
end
gui.Text = "Teleporting players!

and it's not counting down! Help? and my Screen Gui is called "Intermission" and my frame is called "Intermission2" and my textlabel is called "Text'

so help? it's not counting down did I do something wrong?

0
Thanks for everyone that helped! ZAZC_Noob 7 — 7y

3 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

To accomplish this, you can use the For loop! :D

What the For loop does is (if it isn't the generic for) iterate a number of times (or count-up as I should say XP ).

Setting up a For loop is actually fairly easy; this's how you set one up:

for i = STARTVALUE, ENDVALUE, INCREASEMENT do
    -- Pretty self-explanatory names XD
end

And wa-la! You just set up a For loop! :D (Er... I did, actually. ;-; )

Now for the countdown part, the main reason we're doing all of this! >>:O All you need to do is set up the values in the for loop; personally, for countdowns, I like to have the For loop increase & have it subtract the end number; this is how it'd look like:

for i = 1, 20, 1 do -- The start value is 1 (where to begin), the end value is 20 (where to stop), and how much the value increases
    print(20 - i) -- Subtracts 20 by the current iterated number (i, essentially lol )
    wait(1) -- To wait before going onto the next iteration/ looping again; the wait function yields the code for a fixed amount of time, the time being in seconds. :P
end

And, wa-la (again)! That's a countdown code-script-thing... Idk T-T, but it will countdown! (Read the below for a recap on the For loop/ how you set it up.)

Now, to recap/ touch on, the for loop has 3 arguments: the first two are a MUST, while the third one is... meh lol; the first argument, STARTVALUE is the beginning value/ where the iteration begins, the second argument, ENDVALUE is the end value/ where to end, and the third argument, which is, again, optional lol, is how much the iteration increases: here's an example of what I mean:

for i = 0, 50, 2 do
    print(i) -- 0, 2, 4, 6, ...
end

And that's pretty much the ups-and-downs on how to use a For loop. :P

Hope this helped you in any way! :D

0
My answer feels... "Off" to me in some area. e-e TheeDeathCaster 2368 — 7y
0
Then re-check it? ZAZC_Noob 7 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

It's SOMETHING :P

Log in to vote
-1
Answered by
Aepeus 59
7 years ago
for i = 30,1 ,-1 do
wait(1)
script.Parent.Text = "Intermission:" .. i -- change script.parent
end
script.Parent.Text = "Teleporting Players!"

Answer this question