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

Multiple conditions in a while loop?

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.

3 comments

0

maybe the wait(waveIntermission)

0

You can have multiple conditions. Yes. Don't use wait() as one though.

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 .

1 answer

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

1 comment

0

yup

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