isaiah_yt110

Main

Apr 18th, 2021
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. Tool = script.Parent
  2. Handle = Tool:WaitForChild("Handle")
  3.  
  4. Players = game:GetService("Players")
  5. Debris = game:GetService("Debris")
  6. InsertService = game:GetService("InsertService")
  7.  
  8. WhackAnim = Tool:WaitForChild("Whack")
  9. SlashSound = Handle:WaitForChild("SlashSound")
  10. HitSound = Handle:WaitForChild("Hit")
  11.  
  12. Damage = 10 --the damage dealt
  13.  
  14. ReloadTime = 1.45 --time between each swing
  15.  
  16. Kills = 0 --start off with 0 killstreak
  17.  
  18. function TagHumanoid(humanoid, player) --registers you actually hitting the guy
  19. HitSound:Play()
  20. local Creator_Tag = Instance.new("ObjectValue")
  21. Creator_Tag.Name = "creator"
  22. Creator_Tag.Value = player
  23. Debris:AddItem(Creator_Tag, 2)
  24. Creator_Tag.Parent = humanoid
  25. end
  26.  
  27. function UntagHumanoid(humanoid) --removes the tag so that if someone kills the person you tagged, it doesnt register you killing that person.
  28. for i, v in pairs(humanoid:GetChildren()) do
  29. if v:IsA("ObjectValue") and v.Name == "creator" then
  30. v:Destroy()
  31. end
  32. end
  33. end
  34.  
  35. function Blow(Hit) --registers the hit, deals damage to the player, and if the humanoid has 0 health a kill is added into the killstreak.
  36. if Hit and Hit.Parent then
  37. local character = Hit.Parent
  38. local humanoid = character:FindFirstChild("Humanoid")
  39. if Humanoid and Humanoid ~= humanoid and humanoid and Humanoid.Health > 0 and humanoid.Health > 0 then
  40. local Right_Arm = Character:FindFirstChild("Right Arm")
  41. if Right_Arm then
  42. local Joint = Right_Arm:FindFirstChild("RightGrip")
  43. if (Joint and (Joint.Part0 == Handle or Joint.Part1 == Handle)) then
  44. humanoid:TakeDamage(Damage) --deal regular damage or instakill normal health players if a ninja
  45. UntagHumanoid(humanoid)
  46. TagHumanoid(humanoid, Player)
  47. end
  48. end
  49. end
  50. end
  51. end
  52.  
  53. function Activated() --when you swing
  54. if Tool.Enabled then
  55. Tool.Enabled = false
  56. Whack = Humanoid:LoadAnimation(WhackAnim)
  57. if Whack then
  58. Whack:Play()
  59. SlashSound:Play()
  60. end
  61. wait(ReloadTime)
  62. Tool.Enabled = true
  63. end
  64. end
  65.  
  66. function Equipped(mouse) --get everything settled up
  67. Character = Tool.Parent
  68. Player = Players:GetPlayerFromCharacter(Character)
  69. Humanoid = Character:FindFirstChild("Humanoid")
  70. Torso = Character:FindFirstChild("Torso")
  71. if not Humanoid or not Torso then
  72. return
  73. end
  74.  
  75. if not Tool.Enabled then
  76. wait(ReloadTime)
  77. Tool.Enabled = true
  78. end
  79. end
  80.  
  81. function Unequipped()
  82. if Whack then
  83. Whack:Stop() --stop the swing anim so we dont get stuck
  84. end
  85. end
  86.  
  87. --important stuff to register what is what. you need these if you want to do stuff with the tool itself.
  88. Tool.Activated:connect(Activated)
  89. Tool.Equipped:connect(Equipped)
  90. Tool.Unequipped:connect(Unequipped)
  91.  
  92. Handle.Touched:connect(Blow)
  93.  
Advertisement
Add Comment
Please, Sign In to add comment