I want to make a server-sided debounce module script. I want to make a function wherever I use it, it will insert the player and the move into the table. It will be something like this.
local Debounce = {}
function Debounce:FunctionThing(Player, Move)
--Inserts in the table
Player.Name = {
Move = false -- Move is the debounce
}
end)
return Debounce
I tried looking on the developer hub and couldn’t find any help.
Are you trying to add it to the table? If so that’s table.insert(table, item)
Yes, but it comes out with an error.
Please send the error and the full script so I can help.
Debounce Module:
local Debounce = {}
local Debounces = {}
function Debounce:AddDebounce(Player, Move)
if not Debounces[Player] then
Debounce[Player][Move] = false
end
end
return Debounce
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
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)
end)
The PlayerAdded thing is to test it out
Error:
ServerScriptService.Modules.Debounce:7: attempt to index nil with 'M1'