You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am trying to achieve a function to return whether a cooldown is over or not. -
What is the issue? Include screenshots / videos if possible!
I’ve created a module where I store all of my data for weapons/combats, I have my cooldown there. And I try to get the cooldown depending on what the player sends over to the module but it is not functioning(cooldown). I know this method works because I do this but a sloppier version for a different project.
Module Code:
function Globals:FindAbilityData(Data)
if not Data then return end
if Data.Primary then
return DataDirectory[Data.Primary][Data.ToolName][Data.MoveName][Data.Child]
else
return DataDirectory[Data.ToolName][Data.MoveName][Data.Child]
end
end
function Globals:CooldownValidation(Data)
if not Data then return end
local CooldownTime = Globals:FindAbilityData({Primary = Data.Primary, ToolName = Data.ToolName, MoveName = Data.MoveName, Child = "currentTime"})
local Cooldown = Globals:FindAbilityData({Primary = Data.Primary, ToolName = Data.ToolName, MoveName = Data.MoveName, Child = "CD"})
if os.clock() - CooldownTime >= Cooldown then
CooldownTime = os.clock();
return true
end
end
Ability Data Module:
local Directory = {
["Combat"] = {
["Longsword"] = {
["MouseButton1"] = {
currentTime = os.clock();
Damage = 5;
CD = 1;
};
["Backpack"] = {
currentTime = os.clock();
CD = 0;
};
["Equip"] = {
currentTime = os.clock();
CD = 0;
};
["UnEquip"] = {
currentTime = os.clock();
CD = 0;
};
};
};
}
return Directory
Server Code:
local CooldownValidation = Global:CooldownValidation({Primary = "Combat", ToolName = Tool_Name, MoveName = Move_Name})
if CooldownValidation then
print("We Can use skill")
end