Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Multiple conditions in a while loop?

Asked by 5 years ago
Edited 5 years ago

For some reason, my while loop only loops once. Here's the script:

while wait(waveIntermission) and waveStarted == false do 
    if startWaveEvent and waveStarted == false then
        startWaveEvent:Fire()   
        print("Wave has started")
        waveStarted = true
    end
end

waveStarted variable is always false after the wave has ended, I've checked it.

0
maybe the wait(waveIntermission) hellmatic 1523 — 5y
0
You can have multiple conditions. Yes. Don't use wait() as one though. User#19524 175 — 5y
0
Obviously it's not re-looping because on the wait you're checking if the waveStarted is true, at the end of your code you set waveStarted true, meaning it won't re-loop until waveStarted is false . Next_Byte 21 — 5y

1 answer

Log in to vote
1
Answered by
Aimarekin 345 Moderation Voter
5 years ago

Try putting the wait in the loop, not as a condition.

It is better and it could be a possible fix.

Plus, instead of doing == false, do not, which will be met if the value is false

while not waveStarted do 
    wait(waveIntermission)
    if startWaveEvent and not waveStarted then
        startWaveEvent:Fire()   
        print("Wave has started")
        waveStarted = true
    end
end

Tell me if it still doesn't work

0
yup User#19524 175 — 5y
Ad

Answer this question