Just a simple question but is there a way to add a cooldown to this module script ability?
[UPDATE] I tried adding a cooldown that gets the number form the module scripts but i’m get this error
21:01:18.542 Players.Funnyskyswagway3.PlayerScripts.Keybinds:10: attempt to index nil with ‘Cooldown’ - Client - Keybinds:10
Local Script:
local GameFolder = game.ReplicatedStorage.GameFolder
local Modules = GameFolder.Modules
local PearlModule = require(Modules.PearlAbilities)
local Debounce = true
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(hit, chat)
if chat then return end
local ActivateAbility = PearlModule[hit.KeyCode]
local Cooldown = ActivateAbility.Cooldown
if ActivateAbility and Debounce == true then
Debounce = false
ActivateAbility.Activate()
wait(Cooldown)
Debounce = true
end
end)
Module Script:
local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Abilitys = {
[Enum.KeyCode.Q] = {
Activate = function()
local Gem = Player.Character:WaitForChild("Gem")
if Gem.Light.Brightness == 0 then
Gem.Material = Enum.Material.Neon
TweenService:Create(Gem.Light,TweenInfo.new(1), {Brightness = 10} ):Play()
else
Gem.Material = Enum.Material.SmoothPlastic
TweenService:Create(Gem.Light,TweenInfo.new(0.5), {Brightness = 0} ):Play()
end
end,
}
}
return Abilitys