Advertisement
datderpdoe2

Untitled

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