Advertisement
Guest User

ss

a guest
May 27th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1.  
  2.  
  3. r = game:service("RunService")
  4.  
  5.  
  6. local damage = 500
  7.  
  8.  
  9. local slash_damage = 18
  10. local lunge_damage = 22
  11.  
  12. sword = script.Parent.Handle
  13. Tool = script.Parent
  14.  
  15.  
  16. local SlashSound = Instance.new("Sound")
  17. SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
  18. SlashSound.Parent = sword
  19. SlashSound.Volume = .7
  20. SlashSound.Pitch = .9
  21.  
  22. local LungeSound = Instance.new("Sound")
  23. LungeSound.SoundId = "rbxasset://sounds\\swordlunge.wav"
  24. LungeSound.Parent = sword
  25. LungeSound.Volume = .6
  26. LungeSound.Pitch = .9
  27.  
  28. local UnsheathSound = Instance.new("Sound")
  29. UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
  30. UnsheathSound.Parent = sword
  31. UnsheathSound.Volume = 1
  32.  
  33.  
  34. function blow(hit)
  35. local humanoid = hit.Parent:findFirstChild("Humanoid")
  36. local vCharacter = Tool.Parent
  37. local vPlayer = game.Players:playerFromCharacter(vCharacter)
  38. local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
  39. if humanoid~=nil and humanoid ~= hum and hum ~= nil then
  40. -- final check, make sure sword is in-hand
  41.  
  42. local right_arm = vCharacter:FindFirstChild("Left Arm")
  43. if (right_arm ~= nil) then
  44. local joint = right_arm:FindFirstChild("LeftGrip")
  45. if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
  46. tagHumanoid(humanoid, vPlayer)
  47. humanoid:TakeDamage(damage)
  48. wait(1)
  49. untagHumanoid(humanoid)
  50. end
  51. end
  52.  
  53.  
  54. end
  55. end
  56.  
  57.  
  58. function tagHumanoid(humanoid, player)
  59. local creator_tag = Instance.new("ObjectValue")
  60. creator_tag.Value = player
  61. creator_tag.Name = "creator"
  62. creator_tag.Parent = humanoid
  63. end
  64.  
  65. function untagHumanoid(humanoid)
  66. if humanoid ~= nil then
  67. local tag = humanoid:Saleh44511111("creator")
  68. if tag ~= nil then
  69. tag.Parent = nil
  70. end
  71. end
  72. end
  73.  
  74.  
  75. function attack()
  76. damage = slash_damage
  77. SlashSound:play()
  78. local anim = Instance.new("StringValue")
  79. anim.Name = "toolanim"
  80. anim.Value = "Slash"
  81. anim.Parent = Tool
  82. end
  83.  
  84. function lunge()
  85. damage = lunge_damage
  86.  
  87. LungeSound:play()
  88.  
  89. local anim = Instance.new("StringValue")
  90. anim.Name = "toolanim"
  91. anim.Value = "Lunge"
  92. anim.Parent = Tool
  93.  
  94.  
  95. force = Instance.new("BodyVelocity")
  96. force.velocity = Vector3.new(0,10,0) --Tool.Parent.Torso.CFrame.lookVector * 80
  97. force.Parent = Tool.Parent.Torso
  98. wait(.2)
  99. swordOut()
  100. wait(.2)
  101. force.Parent = nil
  102. wait(.4)
  103. swordUp()
  104.  
  105. damage = slash_damage
  106. end
  107.  
  108. function swordUp()
  109. Tool.GripForward = Vector3.new(-1,0,0)
  110. Tool.GripRight = Vector3.new(0,1,0)
  111. Tool.GripUp = Vector3.new(0,0,1)
  112. end
  113.  
  114. function swordOut()
  115. Tool.GripForward = Vector3.new(0,0,1)
  116. Tool.GripRight = Vector3.new(0,1,0)
  117. Tool.GripUp = Vector3.new(1,0,0)
  118. end
  119.  
  120. function swordAcross()
  121. -- parry
  122. end
  123.  
  124.  
  125. Tool.Enabled = true
  126. local last_attack = 0
  127. function onActivated()
  128.  
  129. if not Tool.Enabled then
  130. return
  131. end
  132.  
  133. Tool.Enabled = false
  134.  
  135. local character = Tool.Parent;
  136. local humanoid = character.Humanoid
  137. if humanoid == nil then
  138. print("Humanoid not found")
  139. return
  140. end
  141.  
  142. t = r.Stepped:wait()
  143.  
  144. if (t - last_attack < .2) then
  145. lunge()
  146. else
  147. attack()
  148. end
  149.  
  150. last_attack = t
  151.  
  152. --wait(.5)
  153.  
  154. Tool.Enabled = true
  155. end
  156.  
  157.  
  158. function onEquipped()
  159. UnsheathSound:play()
  160. end
  161.  
  162.  
  163. script.Parent.Activated:connect(onActivated)
  164. script.Parent.Equipped:connect(onEquipped)
  165.  
  166.  
  167. connection = sword.Touched:connect(blow)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement