Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.75 KB | None | 0 0
  1. -------- wfmp
  2.  
  3. r = game:service("RunService")
  4.  
  5. damageTable = {
  6.     ["TerryMichaelBrunk"] = {slashdamage=3,lungedamage=4};
  7.     ["kidzrock4"] = {slashdamage=1,lungedamage=3}
  8. }
  9.  
  10. local damage = 0
  11.  
  12.  
  13. local slashdamage = 2 --The punch is 3 because its is normal attack
  14. local lungedamage = 4 --Its by 5 when it gets stronger
  15.  
  16. sword = script.Parent.Handle
  17. Tool = script.Parent
  18.  
  19.  
  20. local SlashSound = Instance.new("Sound")
  21. SlashSound.SoundId = "e9eefbccb5894696187ac8739894df5e"
  22. SlashSound.Parent = sword
  23. SlashSound.Volume = .7
  24.  
  25. local LungeSound = Instance.new("Sound")
  26. LungeSound.SoundId = "f624b7d32dced04bdf156f3de5e2032"
  27. LungeSound.Parent = sword
  28. LungeSound.Volume = .6
  29.  
  30. local UnsheathSound = script.Parent.Handle.Sound
  31. UnsheathSound.SoundId = "http://www.sound-effect.com/sounds1/human/fight/punch2.wav"
  32. UnsheathSound.Parent = sword
  33. UnsheathSound.Volume = 1
  34.  
  35.  
  36.  
  37. function blow(hit)
  38.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  39.     local vCharacter = Tool.Parent
  40.     local vPlayer = game.Players:playerFromCharacter(vCharacter)
  41.     local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
  42.     if humanoid~=nil and humanoid ~= hum and hum ~= nil then
  43.         print("SWORD HIT")
  44.         tagHumanoid(humanoid, vPlayer)
  45.         humanoid.Health = humanoid.Health - damage
  46.         wait(1)
  47.         untagHumanoid(humanoid)
  48.     end
  49. end
  50.  
  51.  
  52. function tagHumanoid(humanoid, player)
  53.     local creator_tag = Instance.new("ObjectValue")
  54.     creator_tag.Value = player
  55.     creator_tag.Name = "creator"
  56.     creator_tag.Parent = humanoid
  57. end
  58.  
  59. function untagHumanoid(humanoid)
  60.     if humanoid ~= nil then
  61.         local tag = humanoid:findFirstChild("creator")
  62.         if tag ~= nil then
  63.             tag.Parent = nil
  64.         end
  65.     end
  66. end
  67.  
  68.  
  69. function attack()
  70.     if damageTable[script.Parent:FindFirstAncestor("Model").Name] then
  71.         damage = damageTable[script.Parent:FindFirstAncestor("Model").Name].slashdamage
  72.     else
  73.         damage = slashdamage
  74.     end
  75.     SlashSound:play()
  76.     local anim = Instance.new("StringValue")
  77.     anim.Name = "toolanim"
  78.     anim.Value = "Slash"
  79.     anim.Parent = Tool
  80.         damage = 0
  81. end
  82.  
  83. function lunge()
  84.     if damageTable[script.Parent:FindFirstAncestor("Model").Name] then
  85.         damage = damageTable[script.Parent:FindFirstAncestor("Model").Name].lungedamage
  86.     else
  87.         damage = lungedamage
  88.     end
  89.  
  90.     LungeSound:play()
  91.  
  92.     local anim = Instance.new("StringValue")
  93.     anim.Name = "toolanim"
  94.     anim.Value = "Lunge"
  95.     anim.Parent = Tool
  96.    
  97.    
  98.     force = Instance.new("BodyVelocity")
  99.     force.velocity = Vector3.new(0,0,0) --Tool.Parent.Torso.CFrame.lookVector * 80
  100.    
  101.     force.maxForce = Vector3.new(0,0,0)
  102.    
  103.     force.Parent = Tool.Parent.Torso
  104.     wait(.25)
  105.     swordOut()
  106.     wait(.25)
  107.     force.Parent = nil
  108.     wait(.5)
  109.     swordUp()
  110.  
  111.         damage = 0
  112. end
  113.  
  114. function swordUp()
  115.     Tool.Handle.CanCollide = false
  116.     Tool.GripForward = Vector3.new(-1,0,0)
  117.     Tool.GripRight = Vector3.new(0,1,0)
  118.     Tool.GripUp = Vector3.new(0,0,1)
  119.     Tool.Handle.CanCollide = true
  120. end
  121.  
  122. function swordOut()
  123.     Tool.Handle.CanCollide = false
  124.     Tool.GripForward = Vector3.new(0,0,1)
  125.     Tool.GripRight = Vector3.new(0,-1,0)
  126.     Tool.GripUp = Vector3.new(-1,0,0)
  127.     Tool.Handle.CanCollide = true
  128. end
  129.  
  130. function swordAcross()
  131.     -- parry
  132. end
  133.  
  134.  
  135. Tool.Enabled = true
  136. local last_attack = 0
  137. function onActivated()
  138.  
  139.     if not Tool.Enabled then
  140.         return
  141.     end
  142.  
  143.     Tool.Enabled = false
  144.  
  145.     local character = Tool.Parent;
  146.     local humanoid = character.Humanoid
  147.     if humanoid == nil then
  148.         print("Humanoid not found")
  149.         return
  150.     end
  151.  
  152.     t = r.Stepped:wait()
  153.  
  154.     if (t - last_attack < 2000) then
  155.         lunge()
  156.     else
  157.         attack()
  158.     end
  159.  
  160.     last_attack = t
  161.  
  162.     --wait(.5)
  163.  
  164.     Tool.Enabled = true
  165. end
  166.  
  167.  
  168. function onEquipped()
  169.     UnsheathSound:play()
  170. end
  171.  
  172.  
  173. script.Parent.Activated:connect(onActivated)
  174. script.Parent.Equipped:connect(onEquipped)
  175.  
  176.  
  177. connection = sword.Touched:connect(blow)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement