deathsignature2

sword

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