miguel22x

Untitled

Feb 9th, 2018
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.66 KB | None | 0 0
  1. parts = script.Parent; --Parts Model For The Tank
  2. ignoreList = {script.Parent}; --Table Which The Rays Will Ignore
  3. radius = 10; --Kill Radius For HE Rounds (2*Radius Is Hurt Zone)
  4. dealingdamage = 200
  5. makeRays = false;
  6.  
  7.  
  8.  
  9. --Remove Old Rays
  10. if workspace:findFirstChild("Rays") then
  11. workspace:findFirstChild("Rays"):remove();
  12. end
  13. --Make New Model For Rays If Enabled
  14. if makeRays then
  15. m = Instance.new("Model");
  16. m.Name = "Rays";
  17. m.Parent = workspace;
  18. end
  19.  
  20. --Function For Making New Ray Bricks
  21. function makeRay(cframe, size)
  22. local p = Instance.new("Part")
  23. p.Name = "RayPart"
  24. p.BrickColor = BrickColor.new("Bright red")
  25. p.Transparency = 0.5
  26. p.Anchored = true
  27. p.CanCollide = false
  28. p.TopSurface = Enum.SurfaceType.Smooth
  29. p.BottomSurface = Enum.SurfaceType.Smooth
  30. p.formFactor = Enum.FormFactor.Custom
  31. p.CFrame = cframe
  32. p.Size = size
  33. p.Parent = m
  34. ignoreList[#ignoreList+1] = p
  35. end
  36.  
  37. local flash = parts.Parent.Gun.Muzzle:clone()
  38.  
  39.  
  40. flash.Parent = game.Workspace
  41.  
  42.  
  43. flash.Anchored = true
  44.  
  45. parts.Parent.Gun.Muzzle.Sound:Play();
  46. local FL = flash.PointLight:clone()
  47. FL.Parent = flash
  48. FL.Enabled = true
  49. local Flashy = flash.Flash:clone()
  50. Flashy.Parent = flash
  51. Flashy.Enabled = true
  52. game.Debris:AddItem(FL, .07)
  53. game.Debris:AddItem(Flashy, 2)
  54. game.Debris:AddItem(flash, .08)
  55.  
  56. round = Instance.new("Part", user)
  57. round.Name = "RayPart"
  58. round.Transparency = 0
  59. round.Anchored = true
  60. round.CanCollide = true
  61. round.TopSurface = Enum.SurfaceType.Smooth
  62. round.BottomSurface = Enum.SurfaceType.Smooth
  63. round.Material = Enum.Material.Neon
  64. round.formFactor = Enum.FormFactor.Custom
  65. round.BrickColor = BrickColor.new("Daisy orange")
  66. yOffset = -0.2
  67.  
  68. local PL = Instance.new("PointLight")
  69. PL.Parent = round
  70. PL.Brightness = 50
  71. PL.Color = Color3.new(255, 255, 0)
  72. PL.Range = 10
  73. PL.Shadows = true
  74.  
  75.  
  76. --Offset For Each New Ray For The Bullet's Trajectory
  77. local offset = (parts.Parent.Gun.Muzzle.CFrame*CFrame.new(math.random(-5,5)/3,100,math.random(-5,5)/3).p
  78. - parts.Parent.Gun.Muzzle.Position).unit
  79. *script.Parent.Stats.GunVelocity.Value
  80. local point1 = parts.Parent.Gun.Muzzle.Position
  81. --Loop For Making Rays For The Bullet's Trajectory
  82. for i = 1, 30 do
  83. local thisOffset = offset + Vector3.new(0, yOffset*(i-1), 0)
  84. local travelRay = Ray.new(point1,thisOffset)
  85. local hit, position = workspace:FindPartOnRay(travelRay, parts.Parent)
  86.  
  87. local distance = (position - point1).magnitude
  88. round.Size = Vector3.new(.6, distance, .6)
  89. round.CFrame = CFrame.new(position, point1)
  90. * CFrame.new(0, 0, -distance/2)
  91. * CFrame.Angles(math.rad(90),0,0)
  92. round.Parent = workspace
  93. point1 = point1 + thisOffset
  94.  
  95.  
  96.  
  97. if hit then
  98. round:remove()
  99. local e = Instance.new("Explosion")
  100. e.BlastRadius = 5
  101. e.BlastPressure = 0
  102. e.Position = position
  103. e.Parent = workspace
  104. e.DestroyJointRadiusPercent = 0
  105.  
  106.  
  107.  
  108. if hit and hit.Parent then
  109. if hit.Parent:FindFirstChild("Humanoid") then
  110. return hit.Parent.Humanoid
  111. elseif hit.Parent.Parent:FindFirstChild("Humanoid") then
  112. return hit.Parent.Parent.Humanoid
  113.  
  114. elseif hit.Parent.Parent.Hull:FindFirstChild("FrontArmor") then
  115. print("Voce danificou a frente")
  116. local HitSound = hit.Parent:findFirstChild("Pen"):Clone()
  117. HitSound.Parent = hit
  118. HitSound:Play()
  119. hit.Parent.Parent:findFirstChild("Damage").Value = hit.Parent.Parent:findFirstChild("Damage").Value - dealingdamage /2
  120.  
  121. if hit.Parent.Parent:findFirstChild("Damage").Value<1 and hit.Parent.Parent:findFirstChild("Destroyed").Value == false then
  122.  
  123. local DestroyScript = hit.Parent.Parent:findFirstChild("DestroyScript"):clone()
  124. DestroyScript.Parent = hit.Parent.Parent
  125. DestroyScript.Disabled = false
  126.  
  127. print("Veiculo desabilitado")
  128.  
  129.  
  130. end
  131.  
  132. elseif hit.Name == "Left Arm" or hit.Name == "Left Leg" or hit.Name == "Right Arm" or hit.Name == "Right Leg" or hit.Name == "Torso" or hit.Name == "HumanoidRootPart" then
  133. hit.Parent:findFirstChild("Humanoid").Health = hit.Parent:findFirstChild("Humanoid").Health - dealingdamage
  134. print("Direct Hit a Player lmao")
  135.  
  136. elseif hit.Parent.Name == "Face" then
  137. hit.Parent.Parent:findFirstChild("Humanoid").Health = hit.Parent.Parent:findFirstChild("Humanoid").Health - dealingdamage
  138. print("Direct Hit a Morph of a Player lmao")
  139.  
  140.  
  141.  
  142. end
  143. end
  144.  
  145.  
  146.  
  147. local players = game.Players:getChildren()
  148. for i = 1, #players do
  149.  
  150.  
  151. if players[i].TeamColor ~= script.Parent.Parent.Tank.Value then --if he's not an ally
  152. character = players[i].Character
  153. torso = character:findFirstChild'Torso'
  154. if character and torso then
  155.  
  156. torsoPos = torso.Position
  157. origPos = round.Position
  158.  
  159. local ray = Ray.new(origPos, torsoPos-origPos)
  160. local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignoreList)
  161. if hit then
  162. if hit.Parent == character then
  163. human = hit.Parent:findFirstChild("Humanoid")
  164. human2 = hit.Parent.Parent:findFirstChild("Humanoid")
  165. if human then
  166. distance = (position-origPos).magnitude
  167. print("Distance from "..character.Name.." = "..distance)
  168. if distance <= 2*radius then
  169. torso.Velocity = (torso.Position - position).unit * 100;
  170. human:takeDamage(100-(distance-radius)*(100/radius))
  171.  
  172. -- If player died
  173. if human.Health <= 0 then
  174. torso.Velocity = (torso.Position - position).unit * 10;
  175. print("Dead");
  176. end
  177.  
  178. print("Took "..(100-(distance-radius)*(100/radius)).." Damage")
  179. end
  180. elseif human2 then
  181. distance = (position-origPos).magnitude
  182. print("Distance from "..character.Name.." = "..distance)
  183. if distance <= 2*radius then
  184. torso.Velocity = (torso.Position - position).unit * 100;
  185. human:takeDamage(100-(distance-radius)*(100/radius))
  186.  
  187. -- If player died
  188. if human.Health <= 0 then
  189. torso.Velocity = (torso.Position - position).unit * 10;
  190. print("Dead");
  191. end
  192.  
  193. print("Took "..(100-(distance-radius)*(100/radius)).." Damage")
  194. end
  195. end
  196. else print("Didn't hit Target")
  197. end
  198. if makeRays then
  199. makeRay(CFrame.new(origPos, position)
  200. * CFrame.new(0, 0, -distance/2), Vector3.new(0.2, 0.2, distance))
  201. end
  202. end
  203. end
  204. end
  205.  
  206.  
  207.  
  208.  
  209.  
  210. round:remove()
  211.  
  212. break
  213. end
  214. wait()
  215. end
  216. if round then
  217. round:remove()
  218. end
  219. script:remove()
Advertisement
Add Comment
Please, Sign In to add comment