Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why this debounce is not working?

Asked by 10 years ago
local credits = false
local SG = script.Parent.Parent.Parent
local debounce = false

script.Parent.MouseButton1Click:connect(function ()
    if credits == false and debounce == false then
        credits = true
        debounce = true
    end 
    if credits == true and debounce == false then
        credits = false
        debounce = true
    end
    if credits == true and debounce == true then
        SG.Credits.Visible = true
        for i = 1, 14 do
            SG.Credits.Position = SG.Credits.Position + UDim2.new(0.05,0,0,0)
            wait(0)
            if i == 14 then
                script.Parent.Text = "Close Credits"
                debounce = false
            end
        end
    end 
    if credits == false and debounce == true then
        for i = 1, 14 do
            SG.Credits.Position = SG.Credits.Position - UDim2.new(0.05,0,0,0)
            wait(0)
            if i == 14 then
                script.Parent.Text = "Credits"
                SG.Credits.Visible = false
                debounce = false
            end
        end
    end
end)

So, the debounce here is to avoid that people that clicks a milion a times per second to open something and bugs the gui, right? Well im using debounce, but when i click alot of times on the button, the gui bugs. Whats the problem?

0
You're setting credits to true and then asking if credits is true. the end if at line 9 looks like it should be elseif. 1waffle1 2908 — 10y
0
Waffle, it is supposed to be like that, credits is the gui. If credits is true, when you click, is false, that will make the gui invisible, and if credits is false and when i click credits is true, the credits gui will be visible, and i already tried to put an elseif DragonOfWar900 397 — 10y

1 answer

Log in to vote
0
Answered by
LevelKap 114
10 years ago

Your script isn't wrong, it's running exactly how you told it to run.

Ad

Answer this question