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
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()
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.
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