I was making an gravity oriented ability and realized I couldn’t reuse the ability because there would be an error that would pop up every time I called the cooldown cancel function.
Here are the lines giving me trouble:
local BALANCINGPANEL = {
["Ability1Cooldown"] = 0,
["Ability2Cooldown"] = 0,
["Ability3Cooldown"] = 0,
["Ability4Cooldown"] = 5,
["Ability5Cooldown"] = 0,
-- Gravity Flux
["GFBaseDamage"] = 70,
["GFStunTime"] = 2
}
function Cooldown(CooldownFolder, Ability, truefalse, duration)
if CooldownFolder:FindFirstChild(Ability) ~= nil and truefalse == true then
return false
end
if truefalse == true then
local Value = Instance.new("NumberValue", CooldownFolder)
Value.Value = duration
Value.Name = Ability
else
game.Debris:AddItem(CooldownFolder:FindFirstChild(Ability),duration)
end
end
...
Cooldown(ConditionsFolder["Cooldowns"], "Ability4", false, BALANCINGPANEL["Ability4Cooldown"])
I looked past it initially because I thought it was a studio bug since I have another entire moveset that uses this cooldown function and call and it works perfectly.
It’s only in this script that I’m having the issue so if anyone has feedback on what the issue could be or if I’ve overlooked something I will happily accept help.
The cooldown value IS already created in an earlier line:
if Cooldown(ConditionsFolder.Cooldowns, "Ability4", true, BALANCINGPANEL.Ability4Cooldown) == false then return end