I want to make a function to set the debounce value for the move.
I have not found any solutions in the developer forum if you found any please send them.
Here is the debounce module
local Debounce = {}
local Debounces = {}
function Debounce:AddDebounce(Player, Move)
if not Debounces[Player.Name] then
Debounces[Player.Name] = Debounces[Player.Name] or {}
end
if not Debounces[Player.Name][Move] then
Debounces[Player.Name][Move] = false
else
return warn(Move.." Debounce already exists.")
end
print(Debounces)
end
function Debounce:Set(Player, Move, SetValue)
if Debounces[Player.Name] and Debounces[Player.Name][Move] then
Debounces[Player][Move] = SetValue
else
return warn("Could not find debounce")
end
end
return Debounce
Here is the moveset module
local Moveset = {
["Combat"] = {
["M1"] = {
Name = "M1";
Cooldown = .25;
FinishCooldown = .7;
Key = Enum.UserInputType.MouseButton1
},
["Block"] = {
Name = "Block";
Cooldown = .25;
Key = Enum.KeyCode.F
},
["Dash"] = {
Name = "Dash";
Cooldown = 1;
Key = Enum.KeyCode.Q
}
}
}
return Moveset
And here is the main script
local Moveset = require(script.Parent.Modules.Moveset)
local Debounce = require(script.Parent.Modules.Debounce)
game.Players.PlayerAdded:Connect(function(Player)
Debounce:AddDebounce(Player, Moveset.Combat.M1.Name)
Debounce:Set(Player, Moveset.Combat.M1.Name, true)
end)
The part I am having issues with
function Debounce:Set(Player, Move, SetValue)
if Debounces[Player.Name] and Debounces[Player.Name][Move] then
Debounces[Player][Move] = SetValue
else
return warn("Could not find debounce")
end
end
I need help since it can’t find the debounce it is looking for.