Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. -- ₪ Kolbias May 12, 2017 Edited June 2, 2017
  2. --[[-----------------------------------------------------------------------------------
  3. >> VARIABLES
  4. -------------------------------------------------------------------------------------]]
  5. local Players = game:FindService("Players")
  6. local Run = game:FindService("RunService")
  7. local Debris = game:FindService("Debris")
  8.  
  9. local Tool = script.Parent
  10. local Sword = Tool:WaitForChild("Handle")
  11.  
  12. local Slash_Sound = Sword:WaitForChild("Slash_Sound")
  13. local Lunge_Sound = Sword:WaitForChild("Lunge_Sound")
  14. local Unsheath_Sound = Sword:WaitForChild("Unsheath_Sound")
  15.  
  16. local Stats = Sword:WaitForChild("Stats")
  17. local Idle_Damage = Stats.Idle.Value
  18. local Slash_Damage = Stats.Slash.Value
  19. local Lunge_Damage = Stats.Lunge.Value
  20.  
  21. local damage = Idle_Damage
  22.  
  23. --[[-----------------------------------------------------------------------------------
  24. >> TAG HUMANOID FUNCTION
  25. -------------------------------------------------------------------------------------]]
  26. local function TagHumanoid(S_Player, Other)
  27. local Tag = Instance.new("ObjectValue")
  28. Tag.Value = S_Player
  29. Tag.Name = "creator"
  30. Tag.Parent = Other
  31. Debris:AddItem(Tag, 0.25)
  32. Other:TakeDamage(damage)
  33. end
  34.  
  35. --[[-----------------------------------------------------------------------------------
  36. >> DAMAGE FUNCTION
  37. -------------------------------------------------------------------------------------]]
  38. local function onTouched(Hit)
  39. local Other = Hit.Parent:FindFirstChild("Humanoid")
  40. if Other then
  41. local Arm = Tool.Parent:FindFirstChild("Right Arm")
  42. if Arm then
  43. local Grip = Arm:FindFirstChild("RightGrip")
  44. if (Grip and (Grip.Part0 == Arm or Grip.Part1 == Sword)) then
  45. local O_Player = Players:GetPlayerFromCharacter(Hit.Parent)
  46. if O_Player then
  47. local S_Player = Players:GetPlayerFromCharacter(Tool.Parent)
  48. if (S_Player and (O_Player.TeamColor ~= S_Player.TeamColor)) then
  49. TagHumanoid(S_Player, Other)
  50. end
  51. else
  52. Other:TakeDamage(damage)
  53. end
  54. end
  55. end
  56. end
  57. end
  58.  
  59. --[[-----------------------------------------------------------------------------------
  60. >> SLASH FUNCTION
  61. -------------------------------------------------------------------------------------]]
  62. local function Slash()
  63. damage = Slash_Damage
  64. Slash_Sound:Play()
  65. local Animation = Instance.new("StringValue")
  66. Animation.Name = "toolanim"
  67. Animation.Value = "Slash"
  68. Animation.Parent = Tool
  69. end
  70.  
  71. --[[-----------------------------------------------------------------------------------
  72. >> LUNGE FUNCTION
  73. -------------------------------------------------------------------------------------]]
  74. local function Lunge()
  75. damage = Lunge_Damage
  76. Lunge_Sound:Play()
  77. local Animation = Instance.new("StringValue")
  78. Animation.Name = "toolanim"
  79. Animation.Value = "Lunge"
  80. Animation.Parent = Tool
  81. wait(0.25)
  82. Tool.GripUp = Vector3.new(1, 0, 0)
  83. wait(0.75)
  84. Tool.GripUp = Vector3.new(0, 0, 1)
  85. end
  86.  
  87.  
  88. --[[-----------------------------------------------------------------------------------
  89. >> UNSHEATH FUNCTION
  90. -------------------------------------------------------------------------------------]]
  91. local function onEquipped()
  92. Unsheath_Sound:Play()
  93. local Humanoid = Tool.Parent.Humanoid
  94. Humanoid.Died:Connect(function()
  95. Debris:AddItem(Tool, 0.75)
  96. end)
  97. end
  98.  
  99. --[[-----------------------------------------------------------------------------------
  100. >> MAIN FUNCTION
  101. -------------------------------------------------------------------------------------]]
  102. local Enabled = true
  103. local Last_Attack = 0
  104.  
  105. local function onActivated()
  106. if not Enabled then
  107. return
  108. end
  109. Enabled = false
  110. local Cooldown = Run.Stepped:wait()
  111. if (Cooldown - Last_Attack < 0.2) then
  112. Lunge()
  113. else
  114. Slash()
  115. end
  116. Last_Attack = Cooldown
  117. damage = Idle_Damage
  118. Enabled = true
  119. end
  120.  
  121. --[[-----------------------------------------------------------------------------------
  122. >> CONNECTIONS
  123. -------------------------------------------------------------------------------------]]
  124. Tool.Equipped:Connect(onEquipped)
  125. Tool.Activated:Connect(onActivated)
  126. Sword.Touched:Connect(onTouched)
  127.  
  128. -- ₪ Kolbias May 12, 2017 Edited June 2, 2017
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement