Advertisement
4vJorckV5

Untitled

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