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

Where do I move the debounce lines? The debounce is not working.

Where do I move the debounce lines? The debounce is not working.

local debounce = true
local number = 1

function onMouseButton1Click()
	if debounce == false then return end
	for i=0, 1, 0.03125 do
		if number == 1 then
			script.Parent.TextButton.BackgroundTransparency = i
			script.Parent.TextButton.TextTransparency = i
			script.Parent.TextLabel.TextTransparency = i
			wait(0.03125)
			debounce = true
		elseif number == 2 then
			script.Parent:Destroy()
		elseif number == 3 then
			number = 0
		end
	end
	number = number + 1
end

script.Parent.TextButton.MouseButton1Click:connect(onMouseButton1Click)

Thanks!

1 comment

0

I updated my answer. It should work for you now :)

1 answer

✓ Accepted answer

debounce should be at the very start of the function.

local debounce = true
local number = 1

function onMouseButton1Click()
    if debounce == false then return end
    debounce=true
    for i=0, 1, 0.03125 do
        if number == 1 then
            script.Parent.TextButton.BackgroundTransparency = i
            script.Parent.TextButton.TextTransparency = i
            script.Parent.TextLabel.TextTransparency = i
            wait(0.03125)
        elseif number == 2 then
            script.Parent:Destroy()
        elseif number == 3 then
            number = 0
        end
    end
    number = number + 1
    debounce=false
end

script.Parent.TextButton.MouseButton1Click:connect(onMouseButton1Click)

2 comments

0

I updated my question. Is that what you mean? Because it is not working for me. Thanks for you answer though! :)

0

Nvm I figured it out.

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