So I have my code here.
1 | db_value.Value = db |
2 | repeat wait( 1 ) |
3 | db_value = db_value - 1 |
4 | print (db_value) |
5 | until db_value = = 0 --> This is supposed to loop it until the value reaches 0, right? |
6 | end |
This code just loops infinitely even though my goal is to stop it once it reaches 0, how can I fix this?
I already fixed this problem when answering your last question, but I don't mind answering again.
You're forgetting to include .Value
after the db_value
variable on line 3
and line 5
.
1 | db_value.Value = db |
2 | repeat |
3 | wait( 1 ) |
4 | db_value.Value = db_value.Value - 1 |
5 | print (db_value.Value) |
6 | until db_value.Value < = 0 |
7 | end |
you can do this;
1 | db_value.Value = db |
2 | repeat wait( 1 ) |
3 | if db_value ~ = 0 then |
4 | db_value = db_value - 1 |
5 | print (db_value) |
6 | end |
7 | until db_value = = 0 --> This is supposed to loop it until the value reaches 0, right? |
8 | end |
Instead of using repeat, I'd do this:
1 | while db_value > 0 do |
2 | db_value = db_value - 1 |
3 | print (db_value) |
4 | end |