vibrantsinger423

kek turetqwe 2

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