Advertisement
TaylorsRus

Damage

Jan 3rd, 2022
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. local RepStorage = game:GetService("ReplicatedStorage")
  2. local Modules = RepStorage:WaitForChild("Modules")
  3.  
  4. local HitboxModule = require(Modules:WaitForChild("HitboxModule"))
  5. local Ragdoll = require(Modules:WaitForChild("RagdollModule"))
  6. local PlayerData = require(Modules.Data:WaitForChild("PlayerData"))
  7.  
  8. local DamageController = {}
  9.  
  10. function DamageController:DamageHumanoid(Char, DamageTable)
  11.     if not Char:IsDescendantOf(workspace:WaitForChild("LivingThings")) or Char.Humanoid.Health < 1 then
  12.         return
  13.     end
  14.    
  15.     local Hum, HumRP = Char:WaitForChild("Humanoid"), Char:WaitForChild("HumanoidRootPart")
  16.     --local EnemyHum, EnemyRP = Char:WaitForChild("Humanoid"), Char:WaitForChild("HumanoidRootPart")
  17.    
  18.     local Damage = DamageTable[1]
  19.     local BlockBreak = DamageTable[2]
  20.  
  21.     local DataIndex = PlayerData.Stats[Char:GetAttribute("Type")]
  22.    
  23.     local BLOCK_PARTICLE_EMITTION = 30
  24.    
  25.     if Char:GetAttribute("Blocking") then
  26.         if not BlockBreak then
  27.             local BlockSound = HumRP:WaitForChild("BlockSound")
  28.             local BlockParticle = HumRP:WaitForChild("BlockParticle")
  29.            
  30.             BlockSound:Play()
  31.             BlockParticle:Emit(BLOCK_PARTICLE_EMITTION)
  32.         else
  33.             local BlockBreakSound = HumRP:WaitForChild("BlockBreakSound")
  34.            
  35.             BlockBreakSound:Play()
  36.             Char:SetAttribute("Blocking", false)
  37.             Char:SetAttribute("MechanicsDisable", true)
  38.            
  39.             Hum.WalkSpeed = 0
  40.             task.wait(1.65)
  41.            
  42.             Char:SetAttribute("MechanicsDisable", false)
  43.             Hum.WalkSpeed = DataIndex.WalkSpeed
  44.         end
  45.     else
  46.         Hum:TakeDamage(Damage)
  47.     end
  48. end
  49.  
  50. return DamageController
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement