Advertisement
memberhero

Untitled

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