1 | db_value.Value = db |
2 | repeat until db_value.Value = = 0 |
3 | wait( 1 ) |
4 | db_value.Value = db_value - 1 |
5 | print (db) |
6 | end |
So I'm making a debounce and I wanna repeat this, code is pretty self-explanatory. Why does it pretty much crash studio and how can I fix that?
you can change it with this:
1 | db_value.Value = db |
2 | repeat wait() |
3 | db_value.Value = db_value - 1 |
4 | print (db) |
5 | until db_value.Value = = 0 |
6 | end |
This is because you're not doing anything inside of the repeat-until
statement.
The code you want to be repeated until it's condition is true has to be inside of the repeat-until
statement.
1 | repeat |
2 | print (I'll be printing forever. True will never equal false .) |
3 | wait() |
4 | until true = = false |
The code above will print forever since true
will never equal false
. That was an example of how you could use it.
You could also use it like this, which will fit your needs perfectly.
1 | db_value.Value = db |
2 | repeat |
3 | wait( 1 ) |
4 | db_value.Value = db_value.Value - 1 |
5 | print (db) |
6 | until db_value.Value < = 0 |
7 | print ( "db_value equals 0 or less." ) |
If you want to read more about repeat-until statements then feel free to look at the pil.
Reading from what @Harry_TheKing1 said basically, your script renders so fast because there's no wait and you didn't put the below code after the until function after
1 | db_value.Value = db |
2 | repeat |
3 | wait(. 5 ) |
4 | db_value.Value = db_value - 1 |
5 | print (db) |
6 | until db_value.Value = = 0 |
7 | end |