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

Can someone help me with wait times for my script? I just started coding.

I want my part to be clicked and then you have to wait for it to be ready for it to be able to be clicked again. I have already tried "script.Disabled = true wait(3) script.Disabled = false

1 answer

✓ Accepted answer

You can't do this because when you disable the script, it just gets disabled, it will not keep running.

What you should do instead is using a concept called Debounce. Basically you will have a bool (true or false) and if the bool is false (or true) then you would run the script for the part, change the debounce value, then when it's ran you will do the wait part and then return it to false (or true)

local debounce = false

function buttonClicked()
	if debounce == false then -- now we check if the debounce is what it should be so we can run it
		debounce = true	-- you see, now the code will not run because debounce is true
						-- or in other words the debounce is not false, meaning the condition is not met
		-- run your button code here
		wait(3)
		debounce = false -- now the code will be able to run because the debounce is false
	end
end

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