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

How can I put a debounce in my script so it only loops again when i is 1?

Script:

while wait() do
	
	if Players.Value >= 2 then
		
		StatusBar.Text = "Waiting for round start"
		for i = 10, 1, -1 do
			Timer.Text = "Time:"..i
			wait(1) 
		end
		
	elseif Players.Value < 2 then
		StatusBar.Text = "There needs to be more than 1 player to begin the round."
	end
end

2 comments

0

I don't get what you're trying to do here? Is the i to signify a countdown or?

0

@Ryan, Its a basic for loop. I believe what he wants to do is set the minimum to a smaller number when i =1

1 answer

K so you would have to make a debounce variable. idk how else to explain, so ill just put comments in the script


local debounce=false--this is creating the variable
while wait() do
if debounce==false then-- making sure deb is false
debounce=true--setting to true here
    if Players.Value >= 2 then

        StatusBar.Text = "Waiting for round start"
        for i = 10, 1, -1 do
            Timer.Text = "Time:"..i
            wait(1) 
       

    else
        StatusBar.Text = "There needs to be more than 1 player to begin the round."
   end
wait(0.15)
debounce=false--resetting to false

end
end

tell me if it helped

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