Guest User

Untitled

a guest
Aug 19th, 2021
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. -- Copied from Grimgold Periastron Beta
  2.  
  3. local Tool = script.Parent
  4. local Sword = Tool.Handle
  5.  
  6. local vCharacter
  7. local myTorso
  8. local myHumanoid
  9.  
  10. local equipped = false
  11.  
  12. local debris = game:GetService("Debris")
  13.  
  14. function tagHumanoid(humanoid, player)
  15. if humanoid then
  16. local creatorTag = Instance.new("ObjectValue")
  17. creatorTag.Value = player
  18. creatorTag.Name = "creator"
  19. creatorTag.Parent = humanoid
  20. debris:AddItem(creatorTag, 1)
  21. end
  22. end
  23.  
  24. function cut(hit)
  25. local humanoid
  26. local vPlayer
  27. if hit and hit.Parent and myHumanoid then
  28. if hit.Parent.className == "Hat" then
  29. humanoid = hit.Parent.Parent:FindFirstChild("Humanoid")
  30. else
  31. humanoid = hit.Parent:FindFirstChild("Humanoid")
  32. end
  33. vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
  34. if humanoid ~= nil and humanoid ~= myHumanoid then
  35. tagHumanoid(humanoid, vPlayer)
  36. humanoid:TakeDamage(7.5)
  37. end
  38. end
  39. end
  40.  
  41. function onEquipped()
  42. vCharacter = Tool.Parent
  43. myTorso = vCharacter:FindFirstChild("Torso")
  44. myHumanoid = vCharacter:FindFirstChild("Humanoid")
  45. end
  46.  
  47. Tool.Equipped:connect(onEquipped)
  48.  
  49. Sword.Touched:connect(cut)
  50.  
  51. -------- OMG HAX
  52.  
  53. r = game:service("RunService")
  54.  
  55.  
  56. local damage = 5
  57.  
  58. local slash_damage = 10
  59. local lunge_damage = 10
  60.  
  61.  
  62. sword = script.Parent.Handle
  63. Tool = script.Parent
  64.  
  65. local explozion =Instance.new("Explosion")
  66. local SlashSound = Instance.new("Sound")
  67. SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
  68. SlashSound.Parent = sword
  69. SlashSound.Volume = .7
  70.  
  71. local LungeSound = Instance.new("Sound")
  72. LungeSound.SoundId = "rbxasset://sounds\\swordlunge.wav"
  73. LungeSound.Parent = sword
  74. LungeSound.Volume = .6
  75.  
  76. local UnsheathSound = Instance.new("Sound")
  77. UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
  78. UnsheathSound.Parent = sword
  79. UnsheathSound.Volume = 1
  80.  
  81.  
  82. function blow(hit)
  83. local humanoid = hit.Parent:findFirstChild("Humanoid")
  84. local vCharacter = Tool.Parent
  85. local vPlayer = game.Players:playerFromCharacter(vCharacter)
  86. local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
  87. if humanoid~=nil and humanoid ~= hum and hum ~= nil then
  88. -- final check, make sure sword is in-hand
  89.  
  90. local right_arm = vCharacter:FindFirstChild("Right Arm")
  91. if (right_arm ~= nil) then
  92. local joint = right_arm:FindFirstChild("RightGrip")
  93. if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
  94. tagHumanoid(humanoid, vPlayer)
  95. humanoid:TakeDamage(damage)
  96. wait(1)
  97. untagHumanoid(humanoid)
  98. end
  99. end
  100.  
  101.  
  102. end
  103. end
  104.  
  105.  
  106. function tagHumanoid(humanoid, player)
  107. local creator_tag = Instance.new("ObjectValue")
  108. creator_tag.Value = player
  109. creator_tag.Name = "creator"
  110. creator_tag.Parent = humanoid
  111. end
  112.  
  113. function untagHumanoid(humanoid)
  114. if humanoid ~= nil then
  115. local tag = humanoid:findFirstChild("creator")
  116. if tag ~= nil then
  117. tag.Parent = nil
  118. end
  119. end
  120. end
  121.  
  122.  
  123. function attack()
  124. damage = slash_damage
  125. SlashSound:play()
  126. local anim = Instance.new("StringValue")
  127. anim.Name = "toolanim"
  128. anim.Value = "Slash"
  129. anim.Parent = Tool
  130. end
  131.  
  132. function lunge()
  133. damage = lunge_damage
  134.  
  135. LungeSound:play()
  136.  
  137. local anim = Instance.new("StringValue")
  138. anim.Name = "toolanim"
  139. anim.Value = "Lunge"
  140. anim.Parent = Tool
  141.  
  142.  
  143. force = Instance.new("BodyVelocity")
  144. force.velocity = Vector3.new(0,10,0) --Tool.Parent.Torso.CFrame.lookVector * 80
  145. force.Parent = Tool.Parent.Torso
  146. wait(.25)
  147. swordOut()
  148. wait(.25)
  149. force.Parent = nil
  150. wait(.5)
  151. swordUp()
  152.  
  153. damage = slash_damage
  154. end
  155.  
  156. function swordUp()
  157. Tool.GripForward = Vector3.new(-1,0,0)
  158. Tool.GripRight = Vector3.new(0,1,0)
  159. Tool.GripUp = Vector3.new(0,0,1)
  160. end
  161.  
  162. function swordOut()
  163. Tool.GripForward = Vector3.new(0,0,1)
  164. Tool.GripRight = Vector3.new(0,-1,0)
  165. Tool.GripUp = Vector3.new(-1,0,0)
  166. end
  167.  
  168. function swordAcross()
  169. -- parry
  170. end
  171.  
  172.  
  173. Tool.Enabled = true
  174. local last_attack = 0
  175. function onActivated()
  176.  
  177. if not Tool.Enabled then
  178. return
  179. end
  180.  
  181. Tool.Enabled = false
  182.  
  183. local character = Tool.Parent;
  184. local humanoid = character.Humanoid
  185. if humanoid == nil then
  186. print("Humanoid not found")
  187. return
  188. end
  189.  
  190. t = r.Stepped:wait()
  191.  
  192. if (t - last_attack < .2) then
  193. lunge()
  194. else
  195. attack()
  196. end
  197.  
  198. last_attack = t
  199.  
  200. --wait(.5)
  201.  
  202. Tool.Enabled = true
  203. end
  204.  
  205.  
  206. function onEquipped()
  207. UnsheathSound:play()
  208. end
  209.  
  210.  
  211. script.Parent.Activated:connect(onActivated)
  212. script.Parent.Equipped:connect(onEquipped)
  213.  
  214.  
  215. connection = sword.Touched:connect(blow)
Advertisement
Add Comment
Please, Sign In to add comment