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

How Do You Make A Timer?

Asked by 8 years ago

I want to make a game where you have to race and if you are too slow the ground disappears and you fall into lava. The one thing I'm wondering is how do you make a timer? Like countdown from 60 seconds and make the ground disappear? Also I don't know how to put that on a GUI. I know how GUI's work, I just don't know how to put the timer on it so players can see. Thx!

3 answers

Log in to vote
0
Answered by 8 years ago

In my opinion, I think you can do it this way as well: (You can modify it, since I haven't known where would want to put the script into)

local ground = game.ServerStorage.Ground
ground:Clone().Parent = game.Workspace
local secs = 60 -- Any number will do as well :)

for i = secs, 0, -1 do
    script.Parent.Text = 'Time left: '..i -- The text would be 'Time left: (The countdown)'
    wait(1)

    if i == 0 then
        script.Parent.Text = "Time's up!" -- The text would be "Time's up!" when the countdown reaches 0.
        game.Workspace.Ground:Destroy()
    end
end

I hope this would work. Leave a comment if you find any problems.

0
How would I arrange the GUI? PhantomGuy778 2 — 8y
0
put the script into the textlabel/textbox of your GUI (btw, i dont know what u mean... srry ): ) starlebVerse 685 — 8y
0
Also, u can use a frame. (Insert a ScreenGui into StarterGui (in Explorer) and insert a frame/textlabel or textbox) starlebVerse 685 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

here ya go.

seconds = 10 --number of seconds in the timer  --time to wait

  for i = 1,seconds do
        print(seconds-i)
        wait(1)-- waits 1 second


   end


you will need a changed event for the gui though. which so long as your script is under the gui then it would be script.Parent;

0
Thx! PhantomGuy778 2 — 8y
0
wait is about 1 second, not exactly 1. Just note this. JamesLWalker 297 — 8y
0
@Axovua does it really matter? It works either way... Prioxis 673 — 8y
Log in to vote
-1
Answered by 8 years ago

How Would I arrange the GUI? I tried it but didn't quite work my way. How are you setting up the GUI?

0
I put the Screen GUI In StarterGUI, then I placed a TextBox Into The Screen GUI. And then put the script into the TextBox. PhantomGuy778 2 — 8y
0
you do not want to use a textbox, you want to use a frame. scottmike0 40 — 8y

Answer this question