Advertisement
TaylorsRus

SkillHandler

Mar 9th, 2023
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. local SkillHandler = {}
  2.  
  3. local SkillsFolder = script:FindFirstChild("Skills")
  4.  
  5. local CurrentlyCasting = false
  6.  
  7. SkillHandler.Cooldowns = {
  8.     ThunderClap = 5
  9. }
  10.  
  11. function SkillHandler:StartCooldown(Skill)
  12.     local Duration = self.Cooldowns[Skill]
  13.    
  14.     task.wait(Duration)
  15.     CurrentlyCasting = false
  16. end
  17.  
  18. function SkillHandler:CastSkill(Player, Skill)
  19.     if CurrentlyCasting then return end
  20.    
  21.     for _,Module in pairs(SkillsFolder:GetDescendants()) do
  22.         if not Module:IsA("ModuleScript") or Module.Name ~= Skill then
  23.             continue
  24.         end
  25.        
  26.         CurrentlyCasting = true
  27.         Module = require(Module)
  28.         Module:FireSkill(Player)
  29.        
  30.         self:StartCooldown(Skill)
  31.     end
  32. end
  33.  
  34. return SkillHandler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement