Advertisement
Guest User

Punch Script

a guest
Aug 29th, 2020
5,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.80 KB | None | 0 0
  1. local RS = game:GetService("ReplicatedStorage")
  2. local Punch = RS:WaitForChild("Punch")
  3. local Debris = game:GetService("Debris")
  4. local Thit = script:WaitForChild("GetHit")
  5. local Gethit = Thit:WaitForChild("TargetHit")
  6. local Gethit2 = Thit:WaitForChild("TargetHit2")
  7. local TweenService = game:GetService("TweenService")
  8.  
  9. local damage = 10
  10. local currentAtk = 0
  11.  
  12. Punch.OnServerEvent:Connect(function(Player)
  13. local Character = Player.Character
  14. local Humanoid = Character:WaitForChild("Humanoid")
  15. local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
  16.  
  17. local Stand = workspace:FindFirstChild(Player.Name.." Stand"):WaitForChild("Dummy")
  18.  
  19. local folder = Instance.new("Folder",workspace)
  20. folder.Name = Player.Name.." Stand Punch"
  21. Debris:AddItem(folder,.5)
  22.  
  23. if Stand then
  24. currentAtk = currentAtk + 1
  25. local preWeld = Stand:WaitForChild("HumanoidRootPart"):WaitForChild("Stand Weld")
  26. preWeld:Destroy()
  27.  
  28. Stand:WaitForChild("HumanoidRootPart").CFrame = HumanoidRP.CFrame * CFrame.new(0,0,0)
  29.  
  30. local weld = Instance.new("ManualWeld")
  31. weld.Name = "Stand Weld"
  32. weld.Part0 = Stand:WaitForChild("HumanoidRootPart")
  33. weld.Part1 = HumanoidRP
  34. weld.C0 = Stand:WaitForChild("HumanoidRootPart").CFrame:inverse() * HumanoidRP.CFrame
  35. weld.Parent = weld.Part0
  36.  
  37. if currentAtk == 1 then
  38. local Hand = Stand:WaitForChild("Left Arm")
  39. local animControl = Stand:WaitForChild("AnimControl")
  40. local Punch = animControl:LoadAnimation(script:WaitForChild("LeftPunch"))
  41. Punch:Play()
  42.  
  43. local HitBox = script:WaitForChild("HitBox"):Clone()
  44. HitBox.CFrame = Hand.CFrame
  45. HitBox.Parent = folder
  46.  
  47. local Pweld = Instance.new("Weld")
  48. Pweld.Part0 = HitBox
  49. Pweld.Part1 = Hand
  50. Pweld.C0 = HitBox.CFrame:inverse() * Hand.CFrame
  51. Pweld.Parent = Pweld.Part0
  52.  
  53. HitBox.Touched:Connect(function(Hit)
  54. if Hit:IsA("Part") or Hit:IsA("MeshPart") then
  55. if Hit.Parent ~= Character then
  56. local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")
  57. local EHumanoidHit = Hit.Parent:FindFirstChild("HumanoidRootPart")
  58. if EHumanoid or EHumanoidHit then
  59. HitBox:Destroy()
  60. local s = Hand.Punch
  61. s:Play()
  62.  
  63. EHumanoid:TakeDamage(damage)
  64.  
  65. local act = EHumanoid:LoadAnimation(Gethit)
  66. act:Play()
  67.  
  68. if Thit then
  69. local goal = {}
  70. goal.CFrame = CFrame.new((HumanoidRP.CFrame * CFrame.new(0,0,-10)).p, HumanoidRP.CFrame.p)
  71. local info = TweenInfo.new(.5)
  72. local tween = TweenService:Create(EHumanoidHit,info,goal)
  73. tween:Play()
  74. end
  75.  
  76. end
  77. end
  78. end
  79. end)
  80.  
  81. wait()
  82. local preWeld = Stand:WaitForChild("HumanoidRootPart"):WaitForChild("Stand Weld")
  83. preWeld:Destroy()
  84.  
  85. Stand:WaitForChild("HumanoidRootPart").CFrame = HumanoidRP.CFrame * CFrame.new(0,0,0)
  86.  
  87. local weld = Instance.new("ManualWeld")
  88. weld.Name = "Stand Weld"
  89. weld.Part0 = Stand:WaitForChild("HumanoidRootPart")
  90. weld.Part1 = HumanoidRP
  91. weld.C0 = Stand:WaitForChild("HumanoidRootPart").CFrame:inverse() * HumanoidRP.CFrame
  92. weld.Parent = weld.Part0
  93.  
  94. elseif currentAtk == 2 then
  95. local Hand = Stand:WaitForChild("Right Arm")
  96. local animControl = Stand:WaitForChild("AnimControl")
  97. local Punch = animControl:LoadAnimation(script:WaitForChild("RightPunch"))
  98. Punch:Play()
  99.  
  100. local HitBox = script:WaitForChild("HitBox"):Clone()
  101. HitBox.CFrame = Hand.CFrame
  102. HitBox.Parent = folder
  103.  
  104. local Pweld = Instance.new("Weld")
  105. Pweld.Part0 = HitBox
  106. Pweld.Part1 = Hand
  107. Pweld.C0 = HitBox.CFrame:inverse() * Hand.CFrame
  108. Pweld.Parent = Pweld.Part0
  109.  
  110. HitBox.Touched:Connect(function(Hit)
  111. if Hit:IsA("Part") or Hit:IsA("MeshPart") then
  112. if Hit.Parent ~= Character then
  113. local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")
  114. local EHumanoidHit = Hit.Parent:FindFirstChild("HumanoidRootPart")
  115. if EHumanoid or EHumanoidHit then
  116. HitBox:Destroy()
  117. local s = Hand.Punch
  118. s:Play()
  119.  
  120. EHumanoid:TakeDamage(damage)
  121.  
  122. local act = EHumanoid:LoadAnimation(Gethit2)
  123. act:Play()
  124.  
  125. if Thit then
  126. local goal = {}
  127. goal.CFrame = CFrame.new((HumanoidRP.CFrame * CFrame.new(0,0,-10)).p, HumanoidRP.CFrame.p)
  128. local info = TweenInfo.new(.5)
  129. local tween = TweenService:Create(EHumanoidHit,info,goal)
  130. tween:Play()
  131. end
  132.  
  133. end
  134. end
  135. end
  136. end)
  137.  
  138. wait()
  139. local preWeld = Stand:WaitForChild("HumanoidRootPart"):WaitForChild("Stand Weld")
  140. preWeld:Destroy()
  141.  
  142. Stand:WaitForChild("HumanoidRootPart").CFrame = HumanoidRP.CFrame * CFrame.new(0,0,0)
  143.  
  144. local weld = Instance.new("ManualWeld")
  145. weld.Name = "Stand Weld"
  146. weld.Part0 = Stand:WaitForChild("HumanoidRootPart")
  147. weld.Part1 = HumanoidRP
  148. weld.C0 = Stand:WaitForChild("HumanoidRootPart").CFrame:inverse() * HumanoidRP.CFrame
  149. weld.Parent = weld.Part0
  150.  
  151. else
  152. currentAtk = 1
  153. local Hand = Stand:WaitForChild("Left Arm")
  154. local animControl = Stand:WaitForChild("AnimControl")
  155. local Punch = animControl:LoadAnimation(script:WaitForChild("LeftPunch"))
  156. Punch:Play()
  157.  
  158. local HitBox = script:WaitForChild("HitBox"):Clone()
  159. HitBox.CFrame = Hand.CFrame
  160. HitBox.Parent = folder
  161.  
  162. local Pweld = Instance.new("Weld")
  163. Pweld.Part0 = HitBox
  164. Pweld.Part1 = Hand
  165. Pweld.C0 = HitBox.CFrame:inverse() * Hand.CFrame
  166. Pweld.Parent = Pweld.Part0
  167.  
  168. HitBox.Touched:Connect(function(Hit)
  169. if Hit:IsA("Part") or Hit:IsA("MeshPart") then
  170. if Hit.Parent ~= Character then
  171. local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")
  172. local EHumanoidHit = Hit.Parent:FindFirstChild("HumanoidRootPart")
  173. if EHumanoid or EHumanoidHit then
  174. HitBox:Destroy()
  175. local s = Hand.Punch
  176. s:Play()
  177.  
  178. EHumanoid:TakeDamage(damage)
  179.  
  180. local act = EHumanoid:LoadAnimation(Gethit)
  181. act:Play()
  182.  
  183. if Thit then
  184. local goal = {}
  185. goal.CFrame = CFrame.new((HumanoidRP.CFrame * CFrame.new(0,0,-10)).p, HumanoidRP.CFrame.p)
  186. local info = TweenInfo.new(.5)
  187. local tween = TweenService:Create(EHumanoidHit,info,goal)
  188. tween:Play()
  189. end
  190.  
  191. end
  192. end
  193. end
  194. end)
  195.  
  196. wait()
  197. local preWeld = Stand:WaitForChild("HumanoidRootPart"):WaitForChild("Stand Weld")
  198. preWeld:Destroy()
  199.  
  200. Stand:WaitForChild("HumanoidRootPart").CFrame = HumanoidRP.CFrame * CFrame.new(0,0,0)
  201.  
  202. local weld = Instance.new("ManualWeld")
  203. weld.Name = "Stand Weld"
  204. weld.Part0 = Stand:WaitForChild("HumanoidRootPart")
  205. weld.Part1 = HumanoidRP
  206. weld.C0 = Stand:WaitForChild("HumanoidRootPart").CFrame:inverse() * HumanoidRP.CFrame
  207. weld.Parent = weld.Part0
  208.  
  209. end
  210.  
  211. end
  212.  
  213. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement