Advertisement
KINGOFCOOL

Untitled

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