upgradeButton.MouseButton1Click:Connect(function()
local debounce = true
if player.leaderstats.Strength.Value >= currentUpgrade and debounce == true then
debounce = false
--codes here
task.wait(1)
debounce = true
elseif debounce == true then
debounce = false
--codes here
task.wait(1)
debounce = true
end
end)
It’s because you’re setting the debounce after checking for clicks
should be like this instead
local debounce = true
upgradeButton.MouseButton1Click:Connect(function()
if player.leaderstats.Strength.Value >= currentUpgrade and debounce == true then
debounce = false
--codes here
task.wait(1)
debounce = true
elseif debounce == true then
debounce = false
--codes here
task.wait(1)
debounce = true
end
end)
you initialized it within the function, meaning its created inside the function and is not persistent. to fix, initialize debounce outside the function.
Hey, I could be wrong but because you are defining the debounce variable as true on every click event it will always be true…
Just noticed wShadowRBLX beat me to it, let me know if this works though
try the following:
local debounce = true
upgradeButton.MouseButton1Click:Connect(function()
if player.leaderstats.Strength.Value >= currentUpgrade and debounce == true then
debounce = false
--codes here
task.wait(1)
debounce = true
elseif debounce == true then
debounce = false
--codes here
task.wait(1)
debounce = true
end
end)