Ameno__GodOH

Untitled

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