Repeat & until problem

when the roundlength is going to zero the until is not working

repeat
		roundLength.Value = roundLength.Value - 1
		timer.Value = ""..roundLength.Value
		wait(1)
	until
	roundLength.Value == 0 and roundType == "Life"
repeat
	roundLength.Value -= 1
	timer.Value = tostring(roundLength.Value)
	task.wait(1)
until roundLength.Value == 0 and roundType == "Life"

roundtype is not a value

local roundType = ""

Alright, I’ve removed it, try the edit.

You’d need to make sure its value is set to “Life” before the repeat loop runs.

Just to clarify is “timer” a “StringValue” instance?

yes it is a string value thats for the gui

Okay, then the script should work. Add a print afterwards to confirm.

Best to do is this because “repeat wait() until” stops everything under the code until its complete.

while task.wait(1) do
    if roundLength.Value ~= 0 and roundType ~= "Life" then
      roundLength.Value = roundLength.Value - 1
	timer.Value = ""..roundLength.Value
   elseif roundLength.Value == 0 and roundType == "Life" then
    -- // If its done then do whatever u wanted to do here.
   end
end

If you don’t want it in a loop you can do this

local TimerEnded = false

if TimerEnded ~= false then
      -- // If its done then do whatever u wanted to do here.
end

while task.wait(1) do
    if roundLength.Value ~= 0 and roundType ~= "Life" then
      roundLength.Value = roundLength.Value - 1
	timer.Value = ""..roundLength.Value
   elseif roundLength.Value == 0 and roundType == "Life" then
      TimerEnded = true
   end
end

I think your issue was just the indentation of “repeat” and “until”.

Sometimes it’s necessary to yield for some period of time before resuming. You can still add additional instructions inside the repeat until loop.

i tried urs it didnt work btw my main problem also is the roundlength he will run until negative

There’s nothing wrong with the script I provided so it must be something to do with the script itself, would you mind sharing it?

Actually if it is going to negatives then "roundType == “Life” this part of the conditional statement isn’t coming out as true, meaning the repeat until loop will run indefinitely.

repeat
	roundLength.Value -= 1
	timer.Value = tostring(roundLength.Value)
	task.wait(1)
until roundLength.Value <= 0 and roundType == "Life"

it gives me this error
attempt to compare string <= number
image

Just edited, I forgot we cant do wait things on Heartbeat. I changed it to while wait.
Maybe this give a go and see if it works?

If it doesn’t then I think its best that @Limited_Unique to help with this.

That means “roundLength” is a “StringValue” instance.

repeat
	roundLength.Value -= 1
	timer.Value = tostring(roundLength.Value)
	task.wait(1)
until tonumber(roundLength.Value) <= 0 and roundType == "Life"

sorry but i need to use the repeat loops

Shouldn’t roundLength be a NumberValue or IntValue?

1 Like

Yes change it to NumberValue and it should fix your issue.

it can be i will do it cuz i didnt if what i am going to use