Advertisement
Guest User

code

a guest
Oct 23rd, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. script.Parent:WaitForChild("lvl")
  2. Player = game.Players.LocalPlayer
  3. Player:WaitForChild("leaderstats")
  4. local Tool = script.Parent
  5. local Sword = Tool:WaitForChild("Handle")
  6.  
  7. local myCharacter
  8. local myPlayer
  9. local myHumanoid
  10. local myTorso
  11. local myRightArm
  12. local myRightGrip
  13.  
  14. local debris = game:GetService("Debris")
  15. local runServ = game:GetService("RunService")
  16.  
  17. local SlashSound = Instance.new("Sound")
  18. SlashSound.SoundId = "rbxasset://sounds\\SwordSlash.wav"
  19. SlashSound.Parent = Tool
  20. SlashSound.Volume = 0
  21. local Whoosh1Sound
  22. local Whoosh2Sound
  23.  
  24. local SlashAnim
  25. local SpecialAnim
  26. Bob=script.Parent.lvl
  27. BaseDmg = 0.5*Bob.Value
  28. Bob.Changed:connect(function(dmg)
  29. BaseDmg = 0.5 * dmg
  30. end)
  31.  
  32. local lastAttackTime = 0
  33. local thisAttackTime
  34. local TOUCH_DAMAGE = 0
  35. local SLASH_DAMAGE = BaseDmg
  36. local SPECIAL_DAMAGE = BaseDmg
  37.  
  38. local damage = TOUCH_DAMAGE
  39.  
  40. local damageCo
  41.  
  42. Tool.Enabled = true
  43.  
  44. function tagHumanoid(humanoid, player)
  45. if humanoid ~= nil then
  46. creator = Instance.new("ObjectValue")
  47. creator.Name = "creator"
  48. creator.Value = player
  49. creator.Parent = humanoid
  50. debris:addItem(creator, 1)
  51. end
  52. end
  53.  
  54. function untagHumanoid(humanoid)
  55. if humanoid ~= nil then
  56. local creatorTag = humanoid:FindFirstChild("creator")
  57. if creatorTag then creatorTag:Remove() end
  58. end
  59. end
  60.  
  61. function blow(hit)
  62. if hit.Parent then
  63. local hitHumanoid = hit.Parent:FindFirstChild("Humanoid")
  64. myCharacter = Tool.Parent
  65. myHumanoid = myCharacter:FindFirstChild("Humanoid")
  66. myPlayer = game.Players:GetPlayerFromCharacter(myCharacter)
  67. if hitHumanoid ~= nil and myHumanoid ~= nil and myHumanoid ~= hitHumanoid then
  68. myRightArm = myCharacter:FindFirstChild("Right Arm")
  69. if myRightArm then
  70. myRightGrip = myRightArm:FindFirstChild("RightGrip")
  71. if myRightGrip and (myRightGrip.Part0 == Sword or myRightGrip.Part1 == Sword) then
  72. tagHumanoid(hitHumanoid, myPlayer)
  73. hitHumanoid:TakeDamage(damage)
  74. wait(0.1)
  75. untagHumanoid(hitHumanoid)
  76. end
  77. end
  78. end
  79. end
  80. end
  81.  
  82. function damageChanger()
  83. damage = SLASH_DAMAGE
  84. wait(1)
  85. damage = TOUCH_DAMAGE
  86. end
  87.  
  88. function slash()
  89. damageCo = coroutine.create(damageChanger)
  90. coroutine.resume(damageCo)
  91.  
  92. if Whoosh1Sound then Whoosh1Sound:Stop() end
  93. if Whoosh2Sound then Whoosh2Sound:Stop() end
  94. if SpecialAnim then SpecialAnim:Stop() end
  95.  
  96. if SlashSound then SlashSound:Play() end
  97. if SlashAnim then SlashAnim:Play() end
  98. end
  99.  
  100. function special()
  101. damageCo = nil
  102. damage = SPECIAL_DAMAGE
  103.  
  104. if SlashSound then SlashSound:Stop() end
  105. if SlashAnim then SlashAnim:Stop() end
  106.  
  107. if SpecialAnim then SpecialAnim:Play() end
  108.  
  109. wait(.4)
  110. if Whoosh1Sound then Whoosh1Sound:Play() end
  111. wait(.7)
  112. if Whoosh2Sound then Whoosh2Sound:Play() end
  113. wait(.1)
  114.  
  115. damage = TOUCH_DAMAGE
  116.  
  117. end
  118.  
  119. function onActivated()
  120.  
  121. if not Tool.Enabled then return end
  122. Tool.Enabled = false
  123.  
  124. myCharacter = Tool.Parent
  125. if not myCharacter then return end
  126. myHumanoid = myCharacter:FindFirstChild("Humanoid")
  127. if not myHumanoid then return end
  128. RightArm = myCharacter:FindFirstChild("Right Arm")
  129. if not RightArm then return end
  130.  
  131. thisAttackTime = runServ.Stepped:wait()
  132.  
  133. if (thisAttackTime - lastAttackTime < 0.2) then
  134. SpecialAnim = myHumanoid:LoadAnimation(Tool.SlashNStabAttempt2)
  135. Whoosh1Sound = Tool:FindFirstChild("Whoosh1")
  136. Whoosh2Sound = Tool:FindFirstChild("Whoosh2")
  137. special()
  138. else
  139. SlashAnim = myHumanoid:LoadAnimation(Tool.Slash)
  140. slash()
  141. end
  142.  
  143. lastAttackTime = thisAttackTime
  144. Tool.Enabled = true
  145. end
  146.  
  147. function onUnequipped()
  148. if SlashSound then SlashSound:Stop() end
  149. if SlashAnim then SlashAnim:Stop() end
  150. if Whoosh1Sound then Whoosh1Sound:Stop() end
  151. if Whoosh2Sound then Whoosh2Sound:Stop() end
  152. if SpecialAnim then SpecialAnim:Stop() end
  153. end
  154.  
  155. Tool.Activated:connect(onActivated)
  156. Tool.Unequipped:connect(onUnequipped)
  157.  
  158. Sword.Touched:connect(blow)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement