Hasli4

Untitled

Nov 22nd, 2026
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1.  
  2. --------------------------------------------------
  3. -- ПОИСК И АТАКА ЦЕЛЕЙ
  4. -- С ДВУМЯ ВИДАМИ ЗВУКА
  5. --------------------------------------------------
  6.  
  7. local function performHit(player, character, attackerHumanoid, attackerRoot)
  8.  
  9. -- Исключаем самого атакующего
  10. local overlapParams = OverlapParams.new()
  11.  
  12. overlapParams.FilterType = Enum.RaycastFilterType.Exclude
  13. overlapParams.FilterDescendantsInstances = {character}
  14. overlapParams.MaxParts = 100
  15.  
  16. -- Запоминаем уже задетых персонажей
  17. local alreadyHit = {}
  18.  
  19. -- Было ли хотя бы одно попадание
  20. local didHit = false
  21.  
  22. -- Была ли атака отменена
  23. local cancelled = false
  24.  
  25. local finishTime = os.clock() + HIT_WINDOW
  26.  
  27. repeat
  28.  
  29. -- Проверяем, что перчатки всё ещё экипированы
  30. if tool.Parent ~= character then
  31. cancelled = true
  32. break
  33. end
  34.  
  35. -- Создаём невидимую область перед игроком
  36. local hitboxCFrame =
  37. attackerRoot.CFrame * HITBOX_OFFSET
  38.  
  39. local parts = Workspace:GetPartBoundsInBox(
  40. hitboxCFrame,
  41. HITBOX_SIZE,
  42. overlapParams
  43. )
  44.  
  45. for _, part in ipairs(parts) do
  46.  
  47. local targetModel, targetHumanoid =
  48. findHumanoid(part)
  49.  
  50. if targetHumanoid
  51. and targetHumanoid ~= attackerHumanoid
  52. and targetHumanoid.Health > 0
  53. and not alreadyHit[targetHumanoid] then
  54.  
  55. -- Не атакуем персонажей под защитой ForceField
  56. if not targetModel:FindFirstChildOfClass("ForceField") then
  57.  
  58. alreadyHit[targetHumanoid] = true
  59.  
  60. -- Ищем корневую часть противника
  61. local targetRoot =
  62. targetModel:FindFirstChild("HumanoidRootPart")
  63. or targetModel:FindFirstChild("Torso")
  64. or targetModel.PrimaryPart
  65.  
  66. --------------------------------------------------
  67. -- ЗВУК ПОПАДАНИЯ
  68. --------------------------------------------------
  69.  
  70. -- Проигрывается только один раз за удар
  71. if not didHit then
  72.  
  73. if targetRoot then
  74. playSoundAt(
  75. hitSoundTemplate,
  76. targetRoot
  77. )
  78. end
  79.  
  80. didHit = true
  81.  
  82. end
  83.  
  84. -- Записываем убийцу
  85. tagCreator(targetHumanoid, player)
  86.  
  87. -- Отбрасываем и роняем противника
  88. if targetRoot and not targetRoot.Anchored then
  89.  
  90. knockback(
  91. attackerRoot,
  92. targetRoot,
  93. targetModel,
  94. targetHumanoid
  95. )
  96.  
  97. end
  98.  
  99. -- Наносим урон
  100. targetHumanoid:TakeDamage(DAMAGE)
  101.  
  102. print(
  103. player.Name ..
  104. " ударил " ..
  105. targetModel.Name
  106. )
  107.  
  108. end
  109. end
  110. end
  111.  
  112. task.wait(0.04)
  113.  
  114. until os.clock() >= finishTime
  115.  
  116. --------------------------------------------------
  117. -- ЗВУК ВЗМАХА, ЕСЛИ НЕ БЫЛО ПОПАДАНИЯ
  118. --------------------------------------------------
  119.  
  120. if not didHit
  121. and not cancelled
  122. and tool.Parent == character
  123. and attackerRoot.Parent then
  124.  
  125. playSoundAt(
  126. swingSoundTemplate,
  127. handle
  128. )
  129.  
  130. print(player.Name .. " ударил по воздуху")
  131.  
  132. end
  133.  
  134. end
  135.  
Advertisement
Add Comment
Please, Sign In to add comment