miguel22x

script

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