Make sure UseDB is used throughout.
Change BtnBoostDB to UseDB in the second line.
You have used UseDB = false twice. One in each section of the if ValBoost.Value <= 0 loop.
Just remove the UseDB variables inside the condition and change the value outside, once.
Like so:
if ValBoost.Value <= 0 then
clickedButton:Destroy()
lastClickedBoost = nil
clickedButton = nil
InfoFrame.AuraFrame.BoostImage.Image = ""
InfoFrame.AuraFrame.auraNameText.Text = ""
InfoFrame.BoostName.Text = ""
InfoFrame.rng.Text = "X"
end
lastClickedBoost = nil
clickedButton = nil
task.wait()
UseDB = false
I have also changed repeated statements and put them outside the loop because thwy will be ran either way.
And why are you using the debounce check for false, twice? (in the first and second if-statement)
I checked the db twice cause its just not the same db I wanted to put db when I click the button “EquipButton” but that was not working so I deleted it and I just have 1 db now
local db=true --before the function or loop
local function OnBoostClicked(BoostInfo, clickedButton)
if BtnBoostDB == true then
InfoFrame.AuraFrame.BoostImage.Image = BoostInfo.image
InfoFrame.BoostName.Text = BoostInfo.name
InfoFrame.BoostName.TextColor3 = BoostInfo.textColor
InfoFrame.BoostName.Font = BoostInfo.textFont
InfoFrame.rng.Text = "X" .. tostring(BoostInfo.Multiplier)
InfoFrame.Luck.Text = ""
InfoFrame.Speed.Text = ""
InfoFrame.EquipButton.MouseButton1Click:Connect(function()
if db then db=false --right after the click
InfoFrame.EquipButton.Interactable = false
if clickedButton == lastClickedBoost then
if lastClickedBoost == nil then return end
BoostCount -= 1
giveBoost(BoostInfo.name)
updateBoostAmount(clickedButton)
updateMaxBoostText()
OnBoostClicked(BoostInfo, clickedButton)
clickedButton.Active = true
clickedButton.Interactable = true
local ValBoost = player.Boosts:FindFirstChild(clickedButton.Name)
if ValBoost.Value <= 0 then
clickedButton:Destroy()
lastClickedBoost = nil
clickedButton = nil
InfoFrame.AuraFrame.BoostImage.Image = ""
InfoFrame.AuraFrame.auraNameText.Text = ""
InfoFrame.BoostName.Text = ""
InfoFrame.rng.Text = "X"
task.wait(0.1)
InfoFrame.EquipButton.Interactable = true
else
task.wait(0.1)
InfoFrame.EquipButton.Interactable = true
lastClickedBoost = nil
clickedButton = nil
end
end
task.wait(2) --whatever pause works
db=true
end
end)
else
return
end
end
I noticed you said something about 2 db’s (debounces) Not sure what you meant there …
Just pointing out each debounce is solo only. If you need 2 you have to use 2 different variables.
db1 db2 db3 …
This is actually a flag variable using a conditional bounce technique. I guess we call that a debounce now.