My GUI Can still be clicked multiple times?

Try this: Forgot to re-address reply. Sorry, goldenstein64.

local debounce = false

local function click()
    if debounce then
         return
    end
    debounce = true
    -- start code here
    local UI = script.Parent.Parent.Parent -- easier to handle
    local Clothing = UI.Parent.Clothing

    script.Buy:Play()
    UI:TweenPosition(UDim2.new(-0.02, 0, -1, 0), "Out", "Quad", 1, true)
    wait(1)
    
    UI.Visible = false
    Clothing.Visible = true
    Clothing:TweenPosition(UDim2.new(-0.02, 0, 0), "In", "Bounce", 1, true)
    wait(1)

    debounce = false
end

script.Parent.MouseButton1Click:Connect(click)
2 Likes

I discussed the problem with OP sometime earlier in the day. The main issue is that they had LocalScripts in each of their buttons, so the debounce was only local towards the button and not all of the buttons. I suggested that they either use a BoolValue as an external reference value or condense all of the button clicking logic into a single LocalScript; OP picked the former.

This new script would still face that same aforementioned problem.

2 Likes