Cooldowns for abilities acting funny

so ive understood that functions, instead of using the values provided in the parameters end up making their own different variables

right now i have two ability slots, one bound to Q and the other one E, and there would be a system where you could shuffle them around and get new ones
however…
the cooldowns for these abilities dont work as intended

right now im trying to return the cooldown from the function so i can task.wait it where the function is called but it just wont work?

abilitytrack.Ended:Connect(function() --this is the function
			newHitbox:Stop()
			print("returned") --prints when its supposed to
			return abilitycd 
		end)
elseif attack == "e" then
		
		if db == true or ecd == true then return end
		db = true 
		ecd = true
		
		local a = funcs[plr.AbilityE.Value](char, ecd)
		print(a)
		local waittime
		
		repeat task.wait() until a ~= nil 
		print(a)
		
		db = false
		task.wait()
		ecd = false
		
	end

Consider returning cooldown from the methods.
So it becomes:

local cooldown_duration  = funcs[plr.AbilityE.Value](char, ecd)
task.wait(cooldown_duration)

without repeat task.wait() until a ~= nil that never ends?

oh ill try this, i kept trying to return it when the animation ended which caused it not to return

this works for ability cooldowns but not the shared cooldown thats used by everything which prevents you from attacking twice

if db == true or qcd == true then return end
		db = true
		qcd = true
		
		local x = funcs[plr.AbilityQ.Value](char, qcd)
		db = false
		
		task.wait(x)
		qcd = false

There should be shared_cooldown : boolean flag then.
You check it also before handling input.
If it’s the same as ability cooldown then you do not need separate cooldowns for each ability so it’s OK to remove them for cleanup reasons and use one shared_cooldown for everything.
If not then you can do

shared_cooldown = true
task.delay(SHARED_COOLDOWN_DURATION, function()  shared_cooldown = false end)

to keep separate shared_cooldown with own duration..

alright ill look into this, the shared cooldown is used so you cant use other abilities while you are already using one