Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. me = game.Players.kingofnoob1234567
  2.  
  3. if script.Parent.className ~= "HopperBin" then
  4. h = Instance.new("HopperBin",me.Backpack)
  5. h.Name = "Turrets"
  6. script.Parent = h
  7. end
  8.  
  9. bin = script.Parent
  10.  
  11. function prop(part, parent, collide, tran, ref, x, y, z, color, anchor)
  12. part.Parent = parent
  13. part.formFactor = 0
  14. part.CanCollide = collide
  15. part.Transparency = tran
  16. part.Reflectance = ref
  17. part.Size = Vector3.new(x,y,z)
  18. part.BrickColor = BrickColor.new(color)
  19. part.TopSurface = 0
  20. part.BottomSurface = 0
  21. part.Anchored = anchor
  22. part:BreakJoints()
  23. end
  24.  
  25. function weld(w, p, p0, p1, a, b, c, x, y, z)
  26. w.Parent = p
  27. w.Part0 = p0
  28. w.Part1 = p1
  29. w.C1 = CFrame.fromEulerAnglesXYZ(a,b,c) * CFrame.new(x,y,z)
  30. end
  31.  
  32. function mesh(mesh, parent, x, y, z, type)
  33. mesh.Parent = parent
  34. mesh.Scale = Vector3.new(x, y, z)
  35. mesh.MeshType = type
  36. end
  37.  
  38. function placeturret(mainplace)
  39. local turret = Instance.new("Model",workspace)
  40. turret.Name = "Turret"
  41.  
  42. local main = Instance.new("Part")
  43. prop(main, turret, true, 0, 0, 3, 1, 3, "Dark grey", true)
  44. main.CFrame = CFrame.new(mainplace)
  45. mainmesh = Instance.new("CylinderMesh",main)
  46.  
  47. local neck = Instance.new("Part")
  48. prop(neck,turret,true,0,0,1,2,1,"Dark grey", true)
  49. neck.CFrame = CFrame.new(mainplace) * CFrame.new(0,1.1,0)
  50. neckmesh = Instance.new("CylinderMesh",neck)
  51. neckmesh.Scale = Vector3.new(1,1.5,1)
  52.  
  53. local move = Instance.new("Part")
  54. prop(move, turret, false, 0, 0, 1, 1, 5,"Dark grey", false)
  55. move.CFrame = CFrame.new(mainplace) * CFrame.new(0,3,0)
  56.  
  57. local bg = Instance.new("BodyGyro")
  58. bg.Parent = move
  59. bg.maxTorque = Vector3.new(1e+008,1e+008,1e+008)
  60.  
  61. local bp = Instance.new("BodyPosition",move)
  62. bp.maxForce = Vector3.new(1e+008,1e+008,1e+008)
  63. bp.position = bp.Parent.Position
  64.  
  65. local gunner = Instance.new("Part")
  66. gunner.FrontSurface = "Hinge"
  67. prop(gunner,turret,true,0,0,1,1,1,"Dark grey",false)
  68. gunner.CFrame = CFrame.new(mainplace) * CFrame.new(0,3,2.5)
  69.  
  70. local gunweld = Instance.new("Weld")
  71. weld(gunweld,move,move,gunner,0,0,0,0,0,2.5)
  72.  
  73. local sound = Instance.new("Sound",gunner)
  74. sound.Volume = 0.8
  75. sound.Pitch = 4
  76. sound.SoundId = "http://www.roblox.com/asset/?id=2760979"
  77.  
  78. function find(pos)
  79. local list = game.Workspace:children()
  80. local torso = nil
  81. local dist = 40
  82. local temp = nil
  83. local human = nil
  84. local temp2 = nil
  85. for x = 1, #list do
  86. temp2 = list[x]
  87. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  88. temp = temp2:findFirstChild("Torso")
  89. human = temp2:findFirstChild("Humanoid")
  90. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  91. if (temp.Position - pos).magnitude < dist then
  92. torso = temp
  93. dist = (temp.Position - pos).magnitude
  94. end
  95. end
  96. end
  97. end
  98. return torso
  99. end
  100.  
  101. coroutine.resume(coroutine.create(function()
  102. while true do
  103. if gunner.Parent ~= nil then
  104. wait(0.1)
  105. local target = find(gunner.Position)
  106. if target ~= nil then
  107. bg.cframe = CFrame.new(move.Position, target.Position)
  108. local meh = math.random(1,6)
  109. if meh == 1 then
  110. local bulls = {}
  111. local dis = (gunner.Position - target.Position).magnitude
  112. local bullet = Instance.new("Part")
  113. prop(bullet,workspace,false,0,0,1,1,1,"Bright yellow",true)
  114. bullet.CFrame = CFrame.new(gunner.Position, target.Position) * CFrame.new(0,0,-dis/2)
  115. local meu = Instance.new("SpecialMesh")
  116. mesh(meu,bullet,0.23,0.23,dis,"Brick")
  117. local huo = target.Parent:findFirstChild("Humanoid")
  118. huo:TakeDamage(math.random(huo.MaxHealth/34,huo.MaxHealth/8))
  119. local randompitch = math.random(500,1200)/1000
  120. sound.Pitch = randompitch
  121. sound:play()
  122. table.insert(bulls,bullet)
  123. for i=1, math.random(3,6) do
  124. local msi = math.random(8,23)/10
  125. local th = Instance.new("Part")
  126. prop(th,workspace,false,0,0,1,1,1,"Bright yellow",true)
  127. th.CFrame = CFrame.new(gunner.Position,target.Position) * CFrame.new(0,0,-dis)
  128. th.CFrame = th.CFrame * CFrame.Angles(math.random(-100,100),math.random(-100,100),math.random(-100,100))
  129. th.CFrame = th.CFrame * CFrame.new(0,0,-msi/2)
  130. thme = Instance.new("SpecialMesh")
  131. mesh(thme,th,0.13,0.13,msi, "Brick")
  132. table.insert(bulls,th)
  133. for duh=1, math.random(2,5) do
  134. local bag = math.random(5,18)/10
  135. local bah = Instance.new("Part")
  136. prop(bah,workspace,false,0,0,1,1,1,"Bright yellow",true)
  137. bah.CFrame = CFrame.new(th.Position) * CFrame.new(0,0,msi/2)
  138. bah.CFrame = bah.CFrame * CFrame.Angles(math.random(-100,100),math.random(-100,100),math.random(-100,100))
  139. bah.CFrame = bah.CFrame * CFrame.new(0,0,-bag/2)
  140. bahme = Instance.new("SpecialMesh")
  141. mesh(bahme,bah,0.02,0.02,bag, "Brick")
  142. table.insert(bulls,bah)
  143. end
  144. end
  145. coroutine.resume(coroutine.create(function()
  146. for i=1, #bulls do
  147. coroutine.resume(coroutine.create(function()
  148. wait(0.1)
  149. for k=0, 1, 0.25 do
  150. wait()
  151. bulls[i].Transparency = k
  152. end
  153. bulls[i]:remove()
  154. end))
  155. end
  156. end))
  157. end
  158. end
  159. end
  160. end
  161. end))
  162. end
  163.  
  164. bin.Selected:connect(function(mouse)
  165. mouse.Button1Down:connect(function()
  166. placeturret(mouse.Hit.p)
  167. end)
  168. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement