Debounce in while loops

I’m trying to use debounce in while loops but it just doesn’t works

Here is a example of what I’m trying to do:

local running = true

while wait() do
	if running == true then
		print('Hello World!')
	else
		break
	end
end

task.wait(5)
running = false

Because you are using while wait() do, which nevers gets to see running = false.

Have whatever creates your condition (an if or function) and then check your debounce inside it, something like this:

if running = true then 
    print("Hello world!")
    running = false
    task.wait(5)
    running = true
end

Ohh, It’s because I’m using while loops so it never checks what is going to happen next right? That’s why the debounce is not working

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.