I've been trying to make it so that when you click a part there's a black gui that fades in and fades out for a week and could'nt make it. I've tried using this script wich i put in the GUI
local debounce = false
local faded = false
game.ReplicatedStorage.FadeGui.OnClientEvent:Connect(function()
if debounce == false then
debounce = true
if faded == false then
faded = true
for i = 0, 1, 0.05 do
script.Parent:WaitForChild(THE GUI OBJECT YOU WANNA FADE).BackgroundTransparency = i
wait(.05)
end
return -- returning to the beginning of the function to not run the following lines, after setting "faded" to true
else
faded = false
for i = 1, 0, -0.05 do
script.Parent:WaitForChild(THE GUI OBJECT YOU WANNA FADE).BackgroundTransparency = i
wait(.05)
end
debounce = false
end
end)
And then i put this script in the part
script.Parent.ClickDetector.MouseClick:Connect(function(Character)
game.ReplicatedStorage.FadeGui:FireClient(game.Players:WaitForChild("Character.Name")) -- Making a signal
end)
But it didn't work. Then i tried using this script but when i change it it stops working:
--< Variables >
local part = game.Workspace.ClickMe
local frame = script.Parent.Frame
local db = false
local TimeBetweenFade = 3
--< Set up >
frame.BackgroundTransparency = 1
frame.Visible = true
--< Event >
part.ClickDetector.MouseClick:Connect(function()
if not db then
db = true
for i = 1,0,-0.1 do
frame.BackgroundTransparency = i
wait(0.01)
end
print("Faded In")
wait(TimeBetweenFade)
db = false
for k = 0,1,0.1 do
frame.BackgroundTransparency = k
wait(0.01)
end
print("Faded out")
end
end)
Example, if i change the TimeBetweenFade, it stops working. Could anyone please tell me how to do it. Oh and just to clarify, these aren't my scripts, I just found them.

3 comments
you did not set db to false so it only works once
in what script?
both of them