I tried making a countdown timer
1 | local Var 1 = 600 |
2 | for x = 1 , Var 1 do |
3 | script.Parent.Text = Var 1 -x |
4 | wait( 1 ) |
5 | end |
people tried to help me on Roblox discord but they were no help so here is the code I have currently im making an event system where it loads in the map and if people click the join button theyll go to the map im using a regular script in a text thing the text thing is called Text the parent of the text is Event
please someone help me i dont wanna repeat a line of code 600 times
Hello, you that you are setting the starting value to one and the taking minus x.
This is the correct script:
1 | local number = 600 |
2 | for x = number, 1 , - 1 do --third argument is the increment |
3 | script.Parent.Text = x |
4 | wait( 1 ) |
5 | end |
REMEMBER TO ACCEPT THE ANSWER IF IT WORKED
I have a timer as well and I feel that what you're doing is slightly wrong. Rather than doing
1 | local Var 1 = 600 |
2 | for x = 1 , Var 1 do |
3 | script.Parent.Text = Var 1 -x |
4 | wait( 1 ) |
5 | end |
you should do
1 | local Var 1 = 600 |
2 | script.Parent.Text = Var 1 |
3 | for x = 1 , Var 1 do |
4 | Var 1 = Var 1 - 1 |
5 | script.Parent.Text = Var 1 |
6 | wait( 1 ) |
7 | end |
So what this does is it will subtract one from the text and rather than doing do you did just do it like that.
so now it will be 600 and subtract one from it.
or you can do
1 | local Var 1 = 600 |
2 | script.Parent.Text = Var 1 |
3 | for x = 1 , Var 1 do |
4 | script.Parent.Text = script.Parent.Text - 1 |
5 | wait( 1 ) |
6 | end |
They both work the first one is more for you though.
1 | local num = 600 |
2 |
3 | for i = 1 , 600 do |
4 | script.Parent.Text = num |
5 | wait( 1 ) |
6 | num = num - 1 |
7 | print (num) |
8 | end |