Ameno__GodOH

Untitled

Jun 20th, 2025
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 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. local RunService = game:GetService("RunService")
  7.  
  8. local Damage = 10
  9. local AttackCooldown = 0.5
  10. local MaxCombo = 4
  11. local ComboCooldown = 1
  12.  
  13. local Player
  14. local Character
  15. local Humanoid
  16. local Torso
  17. local ToolEquipped = false
  18. local LastAttackTime = 0
  19. local AttackCount = 0
  20.  
  21. local Sounds = {
  22. Slash = Handle:WaitForChild("SwordSlash"),
  23. Lunge = Handle:WaitForChild("SwordLunge"),
  24. Unsheath = Handle:WaitForChild("Unsheath")
  25. }
  26.  
  27. function CheckIfAlive()
  28. return Player and Character and Humanoid and Torso and Humanoid.Health > 0
  29. end
  30.  
  31. function TagHumanoid(humanoid)
  32. local tag = Instance.new("ObjectValue")
  33. tag.Name = "creator"
  34. tag.Value = Player
  35. Debris:AddItem(tag, 2)
  36. tag.Parent = humanoid
  37. end
  38.  
  39. function Blow(hit)
  40. if not hit or not hit.Parent or not CheckIfAlive() or not ToolEquipped then return end
  41. local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
  42. if humanoid and humanoid.Health > 0 and hit.Parent ~= Character then
  43. TagHumanoid(humanoid)
  44. humanoid:TakeDamage(Damage)
  45. end
  46. end
  47.  
  48. local Connection = Handle.Touched:Connect(Blow)
  49.  
  50. function PlayAttackAnimation()
  51. local animName = "Attack" .. tostring(math.clamp(AttackCount, 1, MaxCombo))
  52. local anim = Handle:FindFirstChild(animName)
  53. if anim and Humanoid then
  54. local track = Humanoid:LoadAnimation(anim)
  55. track:Play()
  56. end
  57. end
  58.  
  59. function Activated()
  60. if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then return end
  61.  
  62. local currentTime = tick()
  63.  
  64. local cooldown = AttackCooldown
  65. if AttackCount >= MaxCombo then
  66. cooldown = ComboCooldown
  67. end
  68.  
  69. if currentTime - LastAttackTime < cooldown then return end
  70.  
  71. LastAttackTime = currentTime
  72. AttackCount = AttackCount + 1
  73. if AttackCount > MaxCombo then
  74. AttackCount = 1
  75. end
  76.  
  77. Damage = 10
  78. Sounds.Slash:Play()
  79. PlayAttackAnimation()
  80. end
  81.  
  82. function Equipped()
  83. Character = Tool.Parent
  84. Player = Players:GetPlayerFromCharacter(Character)
  85. Humanoid = Character:FindFirstChildOfClass("Humanoid")
  86. Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
  87.  
  88. if not CheckIfAlive() then return end
  89. ToolEquipped = true
  90. Sounds.Unsheath:Play()
  91. end
  92.  
  93. function Unequipped()
  94. ToolEquipped = false
  95. AttackCount = 0
  96. end
  97.  
  98. Tool.Activated:Connect(Activated)
  99. Tool.Equipped:Connect(Equipped)
  100. Tool.Unequipped:Connect(Unequipped)
Advertisement
Add Comment
Please, Sign In to add comment