Advertisement
IHackShootingGames

Turrent

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