Advertisement
SonicrixLP

Untitled

Aug 28th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. --MADE BY OneLegend (NOT THE SCRIPT) LOCAL SCRIPT: Go to line 4 and put your name where it says "YOUR NAME HERE"
  2.  
  3.  
  4. me = game.Players.sonicrixlp
  5.  
  6.  
  7.  
  8. if script.Parent.className ~= "HopperBin" then
  9.  
  10. h = Instance.new("HopperBin",me.Backpack)
  11.  
  12. h.Name = "Turrets"
  13.  
  14. script.Parent = h
  15.  
  16. end
  17.  
  18.  
  19.  
  20. bin = script.Parent
  21.  
  22.  
  23.  
  24. function prop(part, parent, collide, tran, ref, x, y, z, color, anchor)
  25.  
  26. part.Parent = parent
  27.  
  28. part.formFactor = 0
  29.  
  30. part.CanCollide = collide
  31.  
  32. part.Transparency = tran
  33.  
  34. part.Reflectance = ref
  35.  
  36. part.Size = Vector3.new(x,y,z)
  37.  
  38. part.BrickColor = BrickColor.new(color)
  39.  
  40. part.TopSurface = 0
  41.  
  42. part.BottomSurface = 0
  43.  
  44. part.Anchored = anchor
  45.  
  46. part:BreakJoints()
  47.  
  48. end
  49.  
  50.  
  51.  
  52. function weld(w, p, p0, p1, a, b, c, x, y, z)
  53.  
  54. w.Parent = p
  55.  
  56. w.Part0 = p0
  57.  
  58. w.Part1 = p1
  59.  
  60. w.C1 = CFrame.fromEulerAnglesXYZ(a,b,c) * CFrame.new(x,y,z)
  61.  
  62. end
  63.  
  64.  
  65.  
  66. function mesh(mesh, parent, x, y, z, type)
  67.  
  68. mesh.Parent = parent
  69.  
  70. mesh.Scale = Vector3.new(x, y, z)
  71.  
  72. mesh.MeshType = type
  73.  
  74. end
  75.  
  76.  
  77.  
  78. function placeturret(mainplace)
  79.  
  80. local turret = Instance.new("Model",workspace)
  81.  
  82. turret.Name = "Turret"
  83.  
  84.  
  85.  
  86. local main = Instance.new("Part")
  87.  
  88. prop(main, turret, true, 0, 0, 3, 1, 3, "Dark grey", true)
  89.  
  90. main.CFrame = CFrame.new(mainplace)
  91.  
  92. mainmesh = Instance.new("CylinderMesh",main)
  93.  
  94.  
  95.  
  96. local neck = Instance.new("Part")
  97.  
  98. prop(neck,turret,true,0,0,1,2,1,"Dark grey", true)
  99.  
  100. neck.CFrame = CFrame.new(mainplace) * CFrame.new(0,1.1,0)
  101.  
  102. neckmesh = Instance.new("CylinderMesh",neck)
  103.  
  104. neckmesh.Scale = Vector3.new(1,1.5,1)
  105.  
  106.  
  107.  
  108. local move = Instance.new("Part")
  109.  
  110. prop(move, turret, false, 0, 0, 1, 1, 5,"Dark grey", false)
  111.  
  112. move.CFrame = CFrame.new(mainplace) * CFrame.new(0,3,0)
  113.  
  114.  
  115.  
  116. local bg = Instance.new("BodyGyro")
  117.  
  118. bg.Parent = move
  119.  
  120. bg.maxTorque = Vector3.new(1e+008,1e+008,1e+008)
  121.  
  122.  
  123.  
  124. local bp = Instance.new("BodyPosition",move)
  125.  
  126. bp.maxForce = Vector3.new(1e+008,1e+008,1e+008)
  127.  
  128. bp.position = bp.Parent.Position
  129.  
  130.  
  131.  
  132. local gunner = Instance.new("Part")
  133.  
  134. gunner.FrontSurface = "Hinge"
  135.  
  136. prop(gunner,turret,true,0,0,1,1,1,"Dark grey",false)
  137.  
  138. gunner.CFrame = CFrame.new(mainplace) * CFrame.new(0,3,2.5)
  139.  
  140.  
  141.  
  142. local gunweld = Instance.new("Weld")
  143.  
  144. weld(gunweld,move,move,gunner,0,0,0,0,0,2.5)
  145.  
  146.  
  147.  
  148. local sound = Instance.new("Sound",gunner)
  149.  
  150. sound.Volume = 0.8
  151.  
  152. sound.Pitch = 4
  153.  
  154. sound.SoundId = "http://www.roblox.com/asset/?id=2760979"
  155.  
  156.  
  157.  
  158. function find(pos)
  159.  
  160. local list = game.Workspace:children()
  161.  
  162. local torso = nil
  163.  
  164. local dist = 40
  165.  
  166. local temp = nil
  167.  
  168. local human = nil
  169.  
  170. local temp2 = nil
  171.  
  172. for x = 1, #list do
  173.  
  174. temp2 = list[x]
  175.  
  176. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  177.  
  178. temp = temp2:findFirstChild("Torso")
  179.  
  180. human = temp2:findFirstChild("Humanoid")
  181.  
  182. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  183.  
  184. if (temp.Position - pos).magnitude < dist then
  185.  
  186. torso = temp
  187.  
  188. dist = (temp.Position - pos).magnitude
  189.  
  190. end
  191.  
  192. end
  193.  
  194. end
  195.  
  196. end
  197.  
  198. return torso
  199.  
  200. end
  201.  
  202.  
  203.  
  204. coroutine.resume(coroutine.create(function()
  205.  
  206. while true do
  207.  
  208. if gunner.Parent ~= nil then
  209.  
  210. wait(0.1)
  211.  
  212. local target = find(gunner.Position)
  213.  
  214. if target ~= nil then
  215.  
  216. bg.cframe = CFrame.new(move.Position, target.Position)
  217.  
  218. local meh = math.random(1,6)
  219.  
  220. if meh == 1 then
  221.  
  222. local bulls = {}
  223.  
  224. local dis = (gunner.Position - target.Position).magnitude
  225.  
  226. local bullet = Instance.new("Part")
  227.  
  228. prop(bullet,workspace,false,0,0,1,1,1,"Bright yellow",true)
  229.  
  230. bullet.CFrame = CFrame.new(gunner.Position, target.Position) * CFrame.new(0,0,-dis/2)
  231.  
  232. local meu = Instance.new("SpecialMesh")
  233.  
  234. mesh(meu,bullet,0.23,0.23,dis,"Brick")
  235.  
  236. local huo = target.Parent:findFirstChild("Humanoid")
  237.  
  238. huo:TakeDamage(math.random(huo.MaxHealth/34,huo.MaxHealth/8))
  239.  
  240. local randompitch = math.random(500,1200)/1000
  241.  
  242. sound.Pitch = randompitch
  243.  
  244. sound:play()
  245.  
  246. table.insert(bulls,bullet)
  247.  
  248. for i=1, math.random(3,6) do
  249.  
  250. local msi = math.random(8,23)/10
  251.  
  252. local th = Instance.new("Part")
  253.  
  254. prop(th,workspace,false,0,0,1,1,1,"Bright yellow",true)
  255.  
  256. th.CFrame = CFrame.new(gunner.Position,target.Position) * CFrame.new(0,0,-dis)
  257.  
  258. th.CFrame = th.CFrame * CFrame.Angles(math.random(-100,100),math.random(-100,100),math.random(-100,100))
  259.  
  260. th.CFrame = th.CFrame * CFrame.new(0,0,-msi/2)
  261.  
  262. thme = Instance.new("SpecialMesh")
  263.  
  264. mesh(thme,th,0.13,0.13,msi, "Brick")
  265.  
  266. table.insert(bulls,th)
  267.  
  268. for duh=1, math.random(2,5) do
  269.  
  270. local bag = math.random(5,18)/10
  271.  
  272. local bah = Instance.new("Part")
  273.  
  274. prop(bah,workspace,false,0,0,1,1,1,"Bright yellow",true)
  275.  
  276. bah.CFrame = CFrame.new(th.Position) * CFrame.new(0,0,msi/2)
  277.  
  278. bah.CFrame = bah.CFrame * CFrame.Angles(math.random(-100,100),math.random(-100,100),math.random(-100,100))
  279.  
  280. bah.CFrame = bah.CFrame * CFrame.new(0,0,-bag/2)
  281.  
  282. bahme = Instance.new("SpecialMesh")
  283.  
  284. mesh(bahme,bah,0.02,0.02,bag, "Brick")
  285.  
  286. table.insert(bulls,bah)
  287.  
  288. end
  289.  
  290. end
  291.  
  292. coroutine.resume(coroutine.create(function()
  293.  
  294. for i=1, #bulls do
  295.  
  296. coroutine.resume(coroutine.create(function()
  297.  
  298. wait(0.1)
  299.  
  300. for k=0, 1, 0.25 do
  301.  
  302. wait()
  303.  
  304. bulls[i].Transparency = k
  305.  
  306. end
  307.  
  308. bulls[i]:remove()
  309.  
  310. end))
  311.  
  312. end
  313.  
  314. end))
  315.  
  316. end
  317.  
  318. end
  319.  
  320. end
  321.  
  322. end
  323.  
  324. end))
  325.  
  326. end
  327.  
  328.  
  329.  
  330. bin.Selected:connect(function(mouse)
  331.  
  332. mouse.Button1Down:connect(function()
  333.  
  334. placeturret(mouse.Hit.p)
  335.  
  336. end)
  337.  
  338. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement