Problems with simple Debounces refusing to work properly

I am currently making a simple debounce, under normal circumstances, it should work perfectly fine, I am struggling to understand what’s the issue here?

  • Local Script:
--//Move Variables
local ground_smash = false

userinput.InputBegan:Connect(function(input, isTyping)
	if not isTyping and not attacking then
		enabled = false
		local abilityName = FindAbility(input.KeyCode)
		--// Combat
		if abilityName == "Z_Move" then
			class_template.KeyCode(player, character, root, humanoid, "[Z] - Ground Strike", attacking, 1, ground_smash, 1)		
		end
	end
end)

  • Module (class_template.KeyCode)
local MOVE = {}
MOVE.KeyCode = function(player, char, root, humanoid, nameability, attacking, idk, debounce_name, debounce_delay, random)
	local class = player.Backpack[player.Data.Class.Value]
	local block = char:WaitForChild("Values"):WaitForChild("Blocking")
	local stunned = char:WaitForChild("Values"):WaitForChild("Stunned")

	local classdata = player.Data.Class.Value
	local cooldown = game.ReplicatedStorage.Classes[classdata].Moves[nameability]
	
	local waiter = coroutine.wrap(function()
		if stunned.Value == false and attacking == false then
			if not debounce_name then
				debounce_name = true
				class.Event:FireServer(char, root, humanoid, nameability, nameability, random)
				wait(cooldown.Value)
				print(cooldown.Value)
				print(cooldown)
				debounce_name = false
			end
		end
	end)
	waiter()
end
return MOVE

Outputs:

Here’s what printing cooldown and cooldown.Value printed:
image

Also, these are how I set up my moves and etc. The StringValue has the name of the ability and the Value inside of it has the cooldown
image
image

Showcase of the Debounce not literally working at all

https://i.gyazo.com/f5487d362e611e72091bae59fabbe1fd.mp4

You aren’t changing the value of the debounce in the Localscript. Variables aren’t inherited like that unless you use metatables

The easiest way to convert your current way of doing things is using a BindableEvent

Localscript:

local debounced = {
ground_smash = false
}
BindableEvent.Event:Connect(function(deb, value)
debounced[deb] = value
end)

Modulescript:

BindableEvent:Fire('ground_smash',true) --changes debounce to true in LocalScript)

The method didn’t work at all. The debounce is still has the same problem, I understand that I am using a really weird way but I don’t want to create 5 individual functions for every single ability :pensive: