funtion suppose to do what its name says, create a cooldown and check if that cooldown exist and if its over or not, I think the “CreateCooldown” function isn’t working properly or the way im checking the cooldown using the “CanUse” function is wrong. Any ideas?
local cooldowns = {}
local function CreateCooldown(inputCooldown, cooldown)
cooldowns[inputCooldown] = os.clock()
print("created a cool down for ", inputCooldown)
end
local function CanUse(inputCooldown, cooldown)
print("canUse function fired")
if table.find(cooldowns, inputCooldown) then
print("found ", inputCooldown, " cooldown with a cooldown of ", cooldown)
local last = cooldowns[inputCooldown]
if os.clock() - last >= cooldown then
print(inputCooldown, " cooldown ended")
return true
else
print(inputCooldown, " cooldown did not end")
return false
end
else
return true
end
end
if input == "input" and CanUse("input", 10) == true then
print("parry not in cooldown")
local parryValue = Values:FindFirstChild("Parry")
if parryValue.Value == false then
CreateCooldown("input", 2)
end
else
print("parry in cooldown")
end