Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Do You Make A Timer?

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

✓ Accepted answer

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.

3 comments

0

How would I arrange the GUI?

0

put the script into the textlabel/textbox of your GUI (btw, i dont know what u mean... srry ): )

0

Also, u can use a frame. (Insert a ScreenGui into StarterGui (in Explorer) and insert a frame/textlabel or textbox)

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;

3 comments

0

Thx!

0

wait is about 1 second, not exactly 1. Just note this.

0

@Axovua does it really matter? It works either way...

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

2 comments

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.

0

you do not want to use a textbox, you want to use a frame.

This discussion is preserved as it was. New answers, comments, and votes are closed.