For a thing that actually has to have a cooldown? You used debounce in the right way there BUT it is useless in that code because it only runs once.
Debounce is used to prevent the code of happening again in certain ammount of time, can be like this:
local debounce = true
local cooldown = 2 -- Seconds
someEvent:Connect(function(parameters)
if debounce then
debounce = false -- Ensures that the code doesn't run again meanwhile it's already running
wait(cooldown)
debounce = true -- Allows the event to restart again.
end
end)
There are really other ways to use this, this is just the most common one
You’re always setting debounce to true right before checking it, so it does nothing. You have to put the initialization of debounce outside your hit event handler.
first of all the code is messy second you are waiting .1 secnds per each transparency value third you can just use a for loop
like something like this
local part = path.to.part
local debounce = true
part.Touched:Connect(function(hit)
-- get player
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr and debounce then -- check if plr exists and debounce is equal to true
-- loop through
debounce = false
for transparency = 1,0,.1 do
wait(.1)
-- change it here
plr.PlayerGui.Blackout.Frame.BackgroundTransparency = transparency
end
debounce = true
end
end)
something like that should work
it works like you should expect it to be like transparency fade away stuff