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

How to stop a button from being clicked more then once?

Asked by 11 years ago

Ok,I made script so when you press a button it fades and then in the last part I added a debounce so it can only be clicked once, but your still able to click it,why?

01part = script.Parent
02clicked = false
03part.MouseButton1Click:connect(function()
04---------------Debounce------------------
05 if clicked == false--Checks if clicked is false(Which it should be,because it already been set false)
06    then
07    clicked = true-- Since it false it will turn it true(so we know it's alread been clicked)
08end
09 
10----------------Fade Out------------------
11    for fo = 0,10 do
12        wait(0.1)
13        part.BackgroundTransparency = fo/10--You need to divide to get the precise number(Other way won't work)
14        part.TextTransparency = fo/10
15        if fo/10 ==1
View all 22 lines...

1 answer

Log in to vote
1
Answered by 11 years ago

You need the debounce with the script

01part = script.Parent
02clicked = false
03part.MouseButton1Click:connect(function()
04----------------Fade Out------------------
05if clicked == true then
06    clicked = false
07    for fo = 0,10 do
08        wait(0.1)
09        part.BackgroundTransparency = fo/10--You need to divide to get the precise number(Other way won't work)
10    part.TextTransparency = fo/10
11        if fo/10 ==1 then
12            clicked = false
13        end
14    end
15    end
16end)
Ad

Answer this question