Ameno__GodOH

Untitled

Jun 20th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. local Tool = script.Parent
  2. local Handle = Tool:WaitForChild("Handle")
  3.  
  4. local Players = game:GetService("Players")
  5. local Debris = game:GetService("Debris")
  6.  
  7. local Player
  8. local Character
  9. local Humanoid
  10. local Torso
  11. local ToolEquipped = false
  12.  
  13. local Damage = 10
  14. local AttackCount = 1
  15. local LastAttackTime = 0
  16. local ComboCooldown = 1
  17. local AttackCooldown = 0.5
  18.  
  19. local Hit1Anim
  20. local Hit2Anim
  21. local Hit3Anim
  22. local Hit4Anim
  23.  
  24. local Slash1 = Handle:WaitForChild("Slash1")
  25. local Slash2 = Handle:WaitForChild("Slash2")
  26. local Slash3 = Handle:WaitForChild("Slash3")
  27. local Slash4 = Handle:WaitForChild("Slash4")
  28. local Unsheath = Handle:WaitForChild("Unsheath")
  29.  
  30. function CheckIfAlive()
  31. return Player and Character and Humanoid and Torso and Humanoid.Health > 0
  32. end
  33.  
  34. function TagHumanoid(humanoid)
  35. local tag = Instance.new("ObjectValue")
  36. tag.Name = "creator"
  37. tag.Value = Player
  38. Debris:AddItem(tag, 2)
  39. tag.Parent = humanoid
  40. end
  41.  
  42. function Blow(hit)
  43. if not hit or not hit.Parent or not CheckIfAlive() or not ToolEquipped then return end
  44. local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
  45. if humanoid and humanoid.Health > 0 and hit.Parent ~= Character then
  46. TagHumanoid(humanoid)
  47. humanoid:TakeDamage(Damage)
  48. end
  49. end
  50.  
  51. local Connection = Handle.Touched:Connect(Blow)
  52.  
  53. function LoadAnimations()
  54. if Humanoid then
  55. local anim1 = Handle:FindFirstChild("hit1")
  56. local anim2 = Handle:FindFirstChild("hit2")
  57. local anim3 = Handle:FindFirstChild("hit3")
  58. local anim4 = Handle:FindFirstChild("hit4")
  59.  
  60. if anim1 then Hit1Anim = Humanoid:LoadAnimation(anim1) end
  61. if anim2 then Hit2Anim = Humanoid:LoadAnimation(anim2) end
  62. if anim3 then Hit3Anim = Humanoid:LoadAnimation(anim3) end
  63. if anim4 then Hit4Anim = Humanoid:LoadAnimation(anim4) end
  64. end
  65. end
  66.  
  67. function PlayAttackAnimationAndSound()
  68. if AttackCount == 1 then
  69. if Hit1Anim then Hit1Anim:Stop(); Hit1Anim:Play() end
  70. Slash1:Play()
  71. elseif AttackCount == 2 then
  72. if Hit2Anim then Hit2Anim:Stop(); Hit2Anim:Play() end
  73. Slash2:Play()
  74. elseif AttackCount == 3 then
  75. if Hit3Anim then Hit3Anim:Stop(); Hit3Anim:Play() end
  76. Slash3:Play()
  77. elseif AttackCount == 4 then
  78. if Hit4Anim then Hit4Anim:Stop(); Hit4Anim:Play() end
  79. Slash4:Play()
  80. end
  81. end
  82.  
  83. function Activated()
  84. if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then return end
  85.  
  86. local currentTime = tick()
  87.  
  88. local requiredCooldown = (AttackCount > 4) and ComboCooldown or AttackCooldown
  89.  
  90. if currentTime - LastAttackTime < requiredCooldown then
  91. return
  92. end
  93.  
  94. LastAttackTime = currentTime
  95.  
  96. if AttackCount > 4 then
  97. AttackCount = 1
  98. end
  99.  
  100. PlayAttackAnimationAndSound()
  101.  
  102. AttackCount = AttackCount + 1
  103. end
  104.  
  105. function Equipped()
  106. Character = Tool.Parent
  107. Player = Players:GetPlayerFromCharacter(Character)
  108. Humanoid = Character:FindFirstChildOfClass("Humanoid")
  109. Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
  110.  
  111. if not CheckIfAlive() then return end
  112. ToolEquipped = true
  113. LoadAnimations()
  114. Unsheath:Play()
  115. end
  116.  
  117. function Unequipped()
  118. ToolEquipped = false
  119. AttackCount = 1
  120. end
  121.  
  122. Tool.Activated:Connect(Activated)
  123. Tool.Equipped:Connect(Equipped)
  124. Tool.Unequipped:Connect(Unequipped)
Advertisement
Add Comment
Please, Sign In to add comment