ajcooper2003

Untitled

Sep 20th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.30 KB | None | 0 0
  1. --[[ Triple Turret ]]--[[ Written by TigerBloodd and RMDX ]]------------------------------------------------------------------------------------------------------------------------------------------------
  2. V3 = Vector3.new C3 = Color3.new BN = BrickColor.new CN = CFrame.new CA = CFrame.Angles MR = math.rad MRA = math.random MP = math.pi MH = math.huge UD = UDim2.new
  3. TI = table.insert TR = table.remove CR = coroutine.resume CC = coroutine.create MM = math.min it = Instance.new SoundMinigunFire = "http://www.roblox.com/asset/?id=2692806"
  4. me = game.Players.LocalPlayer Hold = false Sitting = true DecalBulletHole = "http://www.roblox.com/asset/?id=64291961" pcall(function()me.Character.Humanoid.MaxHealth=500 wait() me.Character.Humanoid.Health=500 end)
  5.  
  6. stick = function(hit2,hit)
  7. local weld=Instance.new("Weld")
  8. weld.Part0=hit2
  9. weld.Part1=hit
  10. local HitPos=hit2.Position
  11. local CJ=CN(HitPos)
  12. local C0=hit2.CFrame:inverse() *CJ
  13. local C1=hit.CFrame:inverse() * CJ
  14. weld.C0=C0
  15. weld.C1=C1
  16. weld.Parent=hit2
  17. end
  18.  
  19. function Part(Par, Anc, Colli, Tran, Ref, Col, Siz, Mat, Type)
  20. local p = it("Part")
  21. p.formFactor = "Custom"
  22. p.TopSurface = 0
  23. p.BottomSurface = 0
  24. p.Transparency = Tran
  25. p.Reflectance = Ref
  26. p.Anchored = Anc
  27. p.CanCollide = Colli
  28. p.BrickColor = Col
  29. p.Size = Siz
  30. p.Material = Mat or "Plastic"
  31. p.Locked = true
  32. if Type == "Wedge" then
  33. it("SpecialMesh",p).MeshType = "Wedge"
  34. elseif Type == "Sphere" then
  35. it("SpecialMesh",p).MeshType = "Sphere"
  36. elseif Type == "Cylinder" then
  37. it("CylinderMesh",p)
  38. elseif Type == "Block" then
  39. it("BlockMesh",p)
  40. end
  41. p.Parent = Par
  42. p:BreakJoints()
  43. return p
  44. end
  45.  
  46. minigun=it("Sound",me.Character.Torso)
  47. minigun.SoundId=SoundMinigunFire
  48. minigun.Volume=1
  49. minigun.Pitch=1.75
  50.  
  51. ray = function(Pos,Dir,xxz)
  52. local xxz2=c
  53. if not xxz then
  54. xxz2=nil
  55. end
  56. return workspace:FindPartOnRay(Ray.new(Pos, Dir.unit*999),xxz2)
  57. end
  58.  
  59. pcall(function()me.Character["Turret"]:Remove()end)
  60. mod = it("Model",me.Character)mod.Name="Turret"
  61. base = Part(mod,true,true,0,0,BN("Medium grey"),V3(6,1,6),"Plastic","Cylinder")
  62. p1 = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,4,2),"Plastic","Cylinder")
  63. p2 = Part(mod,true,true,0,0,BN("Medium grey"),V3(3,2,3),"Plastic","Cylinder")
  64. seat = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,1,2.5),"Plastic","Block")
  65. seatb = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,3,1),"Plastic","Block")
  66. han = Part(mod,true,true,0,0,BN("Medium grey"),V3(0.5,4,0.5),"Plastic","Cylinder")
  67. joint = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,6,2),"Plastic","Cylinder")
  68. ballr = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,2,2),"Plastic","Sphere")
  69. balll = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,2,2),"Plastic","Sphere")
  70. rp1 = Part(mod,true,true,0,0,BN("Medium grey"),V3(1.5,4,1.5),"Plastic","Cylinder")
  71. lp1 = Part(mod,true,true,0,0,BN("Medium grey"),V3(1.5,4,1.5),"Plastic","Cylinder")
  72. rp2 = Part(mod,true,true,0,0,BN("Black"),V3(0.75,1,0.75),"Plastic","Cylinder")
  73. lp2 = Part(mod,true,true,0,0,BN("Black"),V3(0.75,1,0.75),"Plastic","Cylinder")
  74. seatm = Part(mod,true,false,1,0,BN("Medium grey"),V3(2,2,2),"Plastic","Block")
  75. mp1 = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,6,2),"Plastic","Cylinder")
  76. mp2 = Part(mod,true,true,0,0,BN("Black"),V3(1,1,1),"Plastic","Cylinder")
  77.  
  78. s=me.Character.Torso.CFrame
  79. TurretFace = function(Pos)
  80. base.CFrame = CN(s.X,1,s.Z+10)
  81. p1.CFrame = base.CFrame*CN(0,1.5,0)
  82. seat.CFrame = CN(base.CFrame.X,5,base.CFrame.Z)
  83. seat.CFrame = CN(seat.Position,Pos)
  84. p2.CFrame = seat.CFrame*CN(0,1,-2)*CA(0,0,MR(90))
  85. seatb.CFrame = seat.CFrame*CN(0,1.15,1.25)*CA(MR(15),0,0)
  86. han.CFrame = p2.CFrame*CN(1,0,1)
  87. joint.CFrame = p2.CFrame
  88. ballr.CFrame = joint.CFrame*CN(0,3,0)
  89. balll.CFrame = joint.CFrame*CN(0,-3,0)
  90. rp1.CFrame = ballr.CFrame*CA(MR(90),0,0)*CN(0,-2,0)
  91. lp1.CFrame = balll.CFrame*CA(MR(90),0,0)*CN(0,-2,0)
  92. rp2.CFrame = rp1.CFrame*CN(0,-1.51,0)
  93. lp2.CFrame = lp1.CFrame*CN(0,-1.51,0)
  94. seatm.CFrame = seat.CFrame*CN(0,1.75,0.5)
  95. mp1.CFrame = joint.CFrame*CA(MR(90),0,0)*CN(0,-3,0)
  96. mp2.CFrame = mp1.CFrame*CN(0,-2.51,0)
  97. end
  98. q = function(f)
  99. CR(CC(function()
  100. f()
  101. end))
  102. end
  103. qi = function(ttz)
  104. local qii = it(ttz[1],ttz[2])
  105. table.foreach(ttz,function(oi,oi2)
  106. if oi ~= 1 and oi ~= 2 then
  107. qii[oi] = oi2
  108. end
  109. end)
  110. return qii
  111. end
  112.  
  113. cn = CN
  114. rd = MR
  115. ca = CA
  116. rn = MRA
  117. v3 = V3
  118.  
  119. DetectSurface = function(pos, part)
  120. local surface = nil
  121. local pospos = part.CFrame
  122. local pos2 = pospos:pointToObjectSpace(pos)
  123. local siz = part.Size
  124. local shaep = part.Shape
  125. if shaep == Enum.PartType.Ball or shaep == Enum.PartType.Cylinder then
  126. surface = {"Anything", CN(pospos.p, pos)*CN(0, 0, -(pospos.p - pos).magnitude+0.12)*CA(MR(-90), 0, 0)}
  127. elseif pos2.Y > ((siz.Y/2)-0.01) then
  128. surface = {"Top", CA(0, 0, 0)}
  129. elseif pos2.Y < -((siz.Y/2)-0.01) then
  130. surface = {"Bottom", CA(-math.pi, 0, 0)}
  131. elseif pos2.X > ((siz.X/2)-0.01) then
  132. surface = {"Right", CA(0, 0, MR(-90))}
  133. elseif pos2.X < -((siz.X/2)-0.01) then
  134. surface = {"Left", CA(0, 0, MR(90))}
  135. elseif pos2.Z > ((siz.Z/2)-0.01) then
  136. surface = {"Back", CA(MR(90), 0, 0)}
  137. elseif pos2.Z < -((siz.Z/2)-0.01) then
  138. surface = {"Front", CA(MR(-90), 0, 0)}
  139. end
  140. return surface
  141. end
  142.  
  143. BulletHole = function(HitPos,HitObj,sc,img)
  144. local Surface = DetectSurface(HitPos, HitObj)
  145. local C = CN(HitPos) * CA(HitObj.CFrame:toEulerAnglesXYZ()) * Surface[2]
  146. if Surface[1] == "Anything" then
  147. C = Surface[2]
  148. end
  149. local bl = Part(mod,true,true,1,0,BN("Black"),V3(2, 0.1, 2),"Plastic","Block") qi({"Decal",bl,Face="Top",Texture=img or DecalBulletHole})
  150. bl.CFrame = C*CN(0,-0.1,0)
  151. if not HitObj.Parent:FindFirstChild("Humanoid") then
  152. bl.Anchored = false
  153. stick(bl,HitObj)
  154. else
  155. bl:Remove()
  156. end
  157. game:GetService("Debris"):AddItem(bl,10)
  158. end
  159.  
  160. TurretShot = function(offset) q(function()
  161. local speed = 10
  162. local bb = Part(mod,true,true,0,0,BN("Black"),V3(0.3,0.45,0.3),"Plastic","Cylinder")
  163. bb.CFrame = offset*CN(0,2.8+(MRA(0,30)/10),0)*CA(MR(MRA(-1000,1000)/1000),MR(MRA(-1000,1000)/1000),MR(MRA(-1000,1000)/1000))
  164. wait()
  165. for i=1,50 do
  166. bhit,bpos=ray(bb.Position,bb.Position - (bb.CFrame *CN(0,-1,0)).p)
  167. if bhit and bpos and (bpos - bb.Position).magnitude < speed then break end
  168. bb.CFrame=bb.CFrame*CN(0,speed,0)*CA(MR(-0.2),0,0)
  169. wait()
  170. end bb.CFrame=bb.CFrame*CN(0,(bpos-bb.Position).magnitude,0) BulletHole(bpos,bhit,1.25)
  171. if MRA(1,15)==1 then
  172. if not bhit.Parent:findFirstChild("Humanoid") and bhit.Name:sub(1,4)~="Base" then
  173. bhit.Anchored = false bhit:BreakJoints()
  174. end
  175. end
  176. local h = bhit.Parent:findFirstChild("Humanoid")
  177. if h then h.Health=h.Health-MRA(5,15) else end bb.Anchored = false stick(bb,bhit) game:service("Debris"):AddItem(bb,10)
  178. end) end
  179.  
  180.  
  181. h = Instance.new("HopperBin",me.Backpack)
  182. h.Name = "Turret"
  183.  
  184. Shoot = function()
  185. wait(0.1)
  186. TurretShot(rp2.CFrame*CA(MR(180),0,0))
  187. TurretShot(lp2.CFrame*CA(MR(180),0,0))
  188. TurretShot(mp2.CFrame*CA(MR(180),0,0))
  189. end
  190. TurretFace(V3(0,1,10))
  191. h.Selected:connect(function(Mouse)
  192. q(function()
  193. while true do
  194. TurretFace(Mouse.Hit.p)
  195. wait()
  196. end
  197. end)
  198. Mouse.Button1Down:connect(function()
  199. Hold = true
  200. while Hold do
  201. minigun:Play()
  202. Shoot()
  203. wait()
  204. end
  205. end)
  206. Mouse.Button1Up:connect(function()
  207. Hold = false
  208. end)
  209. Mouse.KeyDown:connect(function(Key)
  210. if Key == "q" then
  211. if Sitting then
  212. Sitting = false me.Character.Humanoid.Sit = false me.Character.Torso.Anchored = false
  213. else
  214. Sitting = true
  215. q(function()
  216. while Sitting do
  217. me.Character.Humanoid.Sit = true me.Character.Torso.Anchored = true me.Character.Torso.CFrame = seatm.CFrame*CN(0,0.25,0.5)
  218. wait()
  219. end
  220. end)
  221. end
  222. end
  223. end)
  224. end)
Advertisement
Add Comment
Please, Sign In to add comment