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

This keeps looping forever even though it's supposed to stop when db_value is 0?

So I have my code here.

db_value.Value = db
repeat wait(1)
db_value =  db_value -1
print(db_value)
until db_value == 0 --> This is supposed to loop it until the value reaches 0, right?
end

This code just loops infinitely even though my goal is to stop it once it reaches 0, how can I fix this?

3 answers

✓ Accepted answer

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.

db_value.Value = db
repeat 
	wait(1)
	db_value.Value =  db_value.Value -1
	print(db_value.Value)
until db_value.Value <= 0
end

1 comment

0

Yeah, I changed it to local db_value = script.Parent.db.Value

you can do this;

db_value.Value = db
repeat wait(1)
if db_value ~= 0 then
db_value =  db_value -1
print(db_value)
end
until db_value == 0 --> This is supposed to loop it until the value reaches 0, right?
end

Instead of using repeat, I'd do this:

while db_value > 0 do
	db_value =  db_value -1
	print(db_value)
end

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