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

How do I make a script that makes a timer count down from 5?

I am making a mannequin challenge game and I can't figure out how to make it count down from 5 and then say "STAY STILL!" and then if they keep moving for over (0.25) seconds they respawn back at the lobby. I need help on how to make a script that makes a timer that counts down

4 answers

✓ Accepted answer

Here you go my friend! Just create a new script and paste this in there and you should be good to go! Let me know if you have any problems with the code.

local Time = 5

function countDown()
	h = Instance.new("Hint")
	h.Parent = game.Workspace
	wait(2)
	h.Text = "Mannequin Challenge in..."
	wait(1)
	for i = Time,1,-1 do
		h.Text = i
		wait(1)
	end
	h.Text = "Stay Still!"
	wait(2)
	h:Destroy()
end

countDown()

2 comments

0

If you could, please leave an up vote. Thanks!

0

Thanks! Helped a lot!

Hello,
To count down, you could use the following code:

wait(5)
print("Five seconds have passed")

Hope this helps you in the long run.

Greetings. If you wish to display how many seconds left for the countdown timer, you may use this simple method:

local Time = 5
while true do
	print(Time, " seconds left")-- Change this line to how you want the remaining time to be displayed.
	wait(1)
	if Time == 0 then
		print("Time is up!")-- Same with this line.
		break
	else
	Time = Time - 1
	end
end

You can replace the "Time" variable with how long you want until players have to freeze and replace the two print statements with however you want to display the remaining time.

3 comments

0

That is a bunch of unnecessary coding LOL

0

Alright, let's see yours.

0

it doesn't work for me

##Solution

What you're looking for is a for loop. They're rather easy, there are three parameters, starting point, ending point, and increment.

for i = 5, 0, -1 do --For 5 -1 ... until we reach 0 do print i.
    print(i)
end

######Hopefully this answered your question, if it did hit the accept answer button. If you have any questions, leave them in the comments section down below this post.

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