A Nil Debounce; Debounce not working?

So I was making a Flood Escape 2 button system, (again) and I was testing out my script, but my debounce won’t work. I can’t make videos and pictures, though.

Extra-things:

So nothing got printed; no errors. Yes, I showed the whole script. This script is in ServerScriptService reaching from a bindable function from a workspace script. More questions about the surroundings of the script is fine.

Script:

local buttonValue = 1
local nextButtonValue = 2
local debounce = false

local function finalsecond(button)
	debounce = false
	buttonValue = buttonValue + 1
	nextButtonValue = nextButtonValue + 1
	button.Touched.Value = true

end

local function interaction(map)
	local interactions = map.Interactives
	local interactive = interactions:FindFirstChild("Interactive_"..buttonValue)
	local button = map.Buttons:FindFirstChild("Button_"..buttonValue)
	local nextButton = map.Buttons:FindFirstChild("Button_"..nextButtonValue)
	if button:FindFirstChild("_Fade") then
		interactive.Transparency = 1
		interactive.CanCollide = false
	button.Light.BrickColor = BrickColor.new("Really red")
	nextButton.Light.BrickColor = BrickColor.new("Lime green")
	end
	if button:FindFirstChild("_Appear") then
		interactive.Transparency = 0
		interactive.CanCollide = true	
	button.Light.BrickColor = BrickColor.new("Really red")
	nextButton.Light.BrickColor = BrickColor.new("Lime green")
	end
	if button:FindFirstChild("_Unanchor") then
	button.Light.BrickColor = BrickColor.new("Really red")
	nextButton.Light.BrickColor = BrickColor.new("Lime green")
		interactive.Anchored = false
		wait(5)
		interactive.Transparency = 1
		interactive.CanCollide = false
	end
end

local function Touched(map)
	local buttons = map.Buttons
	local button = buttons:FindFirstChild("Button_"..buttonValue)
	local nextButton = buttons:FindFirstChild("Button_"..nextButtonValue)
	spawn(function()
		interaction(map)
	end)
	spawn(function()
		finalsecond(button)
	end)
end

game.ReplicatedStorage.Bindables.ButtonFunction.OnInvoke = function(map)
	map.Buttons:FindFirstChild("Button_"..buttonValue).Hitbox.Touched:Connect(function()
		wait(0.1)
		if map.Buttons:FindFirstChild("Button_"..buttonValue).Touched.Value == false then
			if debounce == false then
				local button = map.Buttons:FindFirstChild("Button_"..buttonValue)
				button.Hitbox:Destroy()
				debounce = true
		Touched(map)
		end
		end
	end)
end
1 Like

Please do not post images of code. Instead, post them as text.

What does “not working” mean? Does it work once then stop working after that? Or does the button activate at all?

1 Like

When we hit (stop at) point B, it won’t make the debounce false.

If the action below this does not run, it probably has to do with this conditional statement. You can check by using print() statements to see if the code runs.

1 Like