Loop doesnt break

So I made this script where it loops so it takes away health and if the Break value is too true then it breaks the code. But it doesnt work. I even checked and the break value goes true correctly but the repeat doesnt break:

repeat
		wait(0.1)
		humanoid:TakeDamage(2)
until player2.PlayerGui.Struggle.Break.Value == true or humanoid.Health <= 2 or script.Parent.Parent.Transformed.Hit.Value == true or humanoid.Parent.Transformed.Value ~= Color3.new(0,0,0) or script.parent.parent.Humanoid.Health <= 0
1 Like

Is the value changing mid execution back to false?
Or once it is set to true, does it stay true.

So theres this gui where if you click space it lowers a int value by 1 so when the intvalue reaches 0 it sets the break value to true. I still havent made it so the break value goes back to normal. So no Its not changing mid script

have you tried a while loop, and when the int is 0 then the value that is running the while loop is set to false?

Well the value change script in not inside with the script. It son another script. And I tried a while true do

no i mean make- I’ll just show you


local runLoop = true

while runLoop do
--your stuff here

    if --[[your condition]] then
    runLoop = false
    end
end

how would I do it for my script? Since it has alot of Checks?

if --[[condition]] and --[[condition]] and so on
1 Like

It didnt work. I tried and it didnt work. I dont know why this is happening.

This is exactly what the repeat loop does, you are just recreating it with while loop syntax.

1 Like

Are there any errors on the Output at all? Also side note, but you forgot to capitalize parent here:

Sorry for the late response but no there aren’t any errors

Try printing out all of your conditional checks, and see if at least one of them is true or not?

repeat
    wait(.1)
    humanoid:TakeDamage(2)

    local Check1 = player2.PlayerGui.Struggle.Break.Value == true
    local Check2 = humanoid.Health <= 2
    local Check3 = script.Parent.Parent.Transformed.Hit.Value == true
    local Check4 = humanoid.Parent.Transformed.Value ~= Color3.new(0,0,0)
    local Check5 = script.Parent.Parent.Humanoid.Health <= 0

    print(Check1, Check2, Check3, Check4, Check5)
until Check1 or Check2 or Check3 or Check4 or Check5

It printed:

false true false false false