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

Everytime I press a button, my Gui fades again. I want it to happen once. How do I use debounce?

Asked by
Cowgato 33
2 years ago
local userinputservice = game:GetService("UserInputService")

userinputservice.InputBegan:Connect(function(input, gameProcessedEvent)

    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.1
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.2
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.3
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.4
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.5
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.6
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.7
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.8
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 0.9
    wait(1)
    script.Parent.ScreenGui.Frame.BackgroundTransparency = 1
    wait(1)

    end)

(this local script is in the StarterGui btw)

0
A debounce is just a Boolean Value (Bool Value) that is set to either true or false. Usually, debounces are checked to see if they are false, and if they are then set them to true so when the check happens again it cannot run the code as the debounce would be set to true instead of false. RazzyPlayz 497 — 2y

Answer this question