Chungle16

Untitled

Sep 25th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.67 KB | None | 0 0
  1. -- mediafire
  2. --[[ TBTurret ]]--
  3. math.randomseed(tick()) Colors={"Bright red","Really red","Bright yellow","Bright orange","New Yeller","Deep orange","Neon orange"}
  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 it = Instance.new Sound = "http://www.roblox.com/asset/?id=81116747" Fire="http://www.roblox.com/asset/?id=10209821" cn = CN rd = MR ca = CA rn = MRA v3 = V3
  6. me = game.Players.LocalPlayer Hold = false Sitting = false DecalBulletHole = "http://www.roblox.com/asset/?id=64291961" pcall(function()me.Character.Humanoid.MaxHealth=500 wait() me.Character.Humanoid.Health=500 end)
  7. stick = function(hit2,hit) local weld=Instance.new("Weld") weld.Part0=hit2 weld.Part1=hit local HitPos=hit2.Position local CJ=CN(HitPos) local C0=hit2.CFrame:inverse() *CJ local C1=hit.CFrame:inverse() * CJ weld.C0=C0 weld.C1=C1 weld.Parent=hit2 end
  8. function Part(Par, Anc, Colli, Tran, Ref, Col, Siz, Mat, Type) local p = it("Part") p.formFactor = "Custom" p.TopSurface = 0 p.BottomSurface = 0 p.Transparency = Tran p.Reflectance = Ref p.Anchored = Anc p.CanCollide = Colli p.BrickColor = Col p.Size = Siz p.Material = Mat or "Plastic" p.Locked = true if Type == "Wedge" then it("SpecialMesh",p).MeshType = "Wedge" elseif Type == "Sphere" then it("SpecialMesh",p).MeshType = "Sphere" elseif Type == "Cylinder" then it("CylinderMesh",p) elseif Type == "Block" then it("BlockMesh",p) end p.Parent = Par p:BreakJoints() return p end
  9. RocketExplode=it("Sound",me.Character.Torso) RocketExplode.SoundId=Sound RocketExplode.Volume=1 RocketExplode.Pitch=1
  10. Fiyah=it("Sound",me.Character.Torso) Fiyah.SoundId=Fire Fiyah.Volume=1 Fiyah.Pitch=1 cam=workspace.CurrentCamera for i,v in pairs(cam:children()) do v:Remove() end
  11. Crown="http://www.roblox.com/asset/?id=20329976" Spike="http://www.roblox.com/asset/?id=1033714"
  12. ray = function(Pos,Dir,xxz) local xxz2=c if not xxz then xxz2=nil end return workspace:FindPartOnRay(Ray.new(Pos, Dir.unit*999),xxz2) end
  13. function Blast(Color,Offset)
  14. local bp=Part(mod,true,false,0,0.15,BN(Colors[math.random(1,#Colors)]),V3(1,1,1),"Plastic") bp.Name="Blast" local bm=it("SpecialMesh",bp) bm.MeshId=Crown bm.Scale=v3(5,4,5) bp.CFrame=Offset
  15. q(function()
  16. for i=-0.2,1,0.12 do
  17. bp.Transparency=i+0.1
  18. bm.Scale=V3(1+(5*1)*i, (2.4*1)+1*i, 1+(5*1)*i)
  19. wait()
  20. end
  21. game:GetService("Debris"):AddItem(bp)
  22. end)
  23. end
  24. --TURRET BUILDING
  25. pcall(function()me.Character["Turret"]:Remove()end)
  26. mod = it("Model",me.Character)mod.Name="Turret"
  27. base = Part(mod,true,true,0,0,BN("Medium grey"),V3(6,1,6),"Plastic","Cylinder")
  28. p1 = Part(mod,true,true,0,0,BN("Medium grey"),V3(1,4,1),"Plastic","Cylinder")
  29. seat = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,0.5,2.5),"Plastic","Block")
  30. seatb = Part(mod,true,true,0,0,BN("Medium grey"),V3(2,3,.5),"Plastic","Block")
  31. seatattachment = Part(mod,true,true,0,0,BN("Medium grey"),V3(1,4,1),"Plastic","Cylinder")
  32. seatatball1=Part(mod,true,true,0,0,BN("Medium grey"),V3(2,2,2),"Plastic","Sphere")
  33. seatattachment2 = Part(mod,true,true,0,0,BN("Medium grey"),V3(1,5,1),"Plastic","Cylinder")
  34. seatatball2=Part(mod,true,true,0,0,BN("Medium grey"),V3(2,2,2),"Plastic","Sphere")
  35. seatattachment3 = Part(mod,true,true,0,0,BN("Medium grey"),V3(1,5,1),"Plastic","Cylinder")
  36. seatatball3=Part(mod,true,true,0,0,BN("Medium grey"),V3(2,2,2),"Plastic","Sphere")
  37. seatattachment4 = Part(mod,true,true,0,0,BN("Medium grey"),V3(1,4,1),"Plastic","Cylinder")
  38. Ball=Part(mod,true,true,0,0,BN("Medium grey"),V3(2,2,2),"Plastic","Sphere")
  39. handp=Part(mod,true,true,0,0,BN("Medium grey"),V3(0.5,2,0.5),"Plastic","Cylinder")
  40. Handle=Part(mod,true,true,0,0,BN("Medium grey"),V3(.5,4,.5),"Plastic","Cylinder")
  41. Barrel=Part(mod,true,true,0,0,BN("Medium grey"),V3(2,5,2),"Plastic","Cylinder")
  42. pit=Part(mod,true,true,0,0,BN("Black"),V3(1.25,1,1.25),"Plastic","Cylinder")
  43. --TURRET BUILDING
  44. function Search(Start, Center, Radius)
  45. function Find(Start, Center, Radius)
  46. for _, Object in pairs(Start:GetChildren()) do
  47. Search(Object, Center, Radius)
  48. Count = 0
  49. for _, Humanoid in pairs(Object:GetChildren()) do
  50. if Humanoid:IsA("Humanoid") then
  51. Count = Count + 1
  52. end
  53. end
  54.  
  55. if Object:IsA("Model") and Count > 0 and Object:FindFirstChild("Torso") ~= nil then
  56. if ( Object:FindFirstChild("Torso").Position - Center.Position ).magnitude < Radius then
  57. if Object == me.Character or Object:findFirstChild("Humanoid") == nil or Object:findFirstChild("Torso") == nil then return end
  58. local bpp = qi({"BodyVelocity",Object.Torso,maxForce=v3(1/0,1/0,1/0),velocity=cn(me.Character.Torso.Position,Object.Torso.Position+v3(0,7.5,0)).lookVector*80}) wait(0.2) bpp:Remove()
  59. for _, Humanoid in pairs(Object:GetChildren()) do
  60. if Humanoid:IsA("Humanoid") then
  61. if Humanoid.MaxHealth > 100000 then
  62. Humanoid.MaxHealth = 100
  63. Humanoid.Health = 100
  64. end
  65. Humanoid:TakeDamage(math.random(50, 90))
  66. end
  67. end
  68. end
  69. end
  70. end
  71. end
  72. Find(Start, Center, Radius)
  73. end
  74.  
  75. s=me.Character.Torso.CFrame
  76. TurretFace = function(Pos)
  77. base.CFrame = CN(s.X,s.Y-2.5,s.Z+10)
  78. p1.CFrame = base.CFrame*CN(0,1.5,0)
  79. seat.CFrame = CN(base.CFrame.X,base.CFrame.Y+3.5,base.CFrame.Z) seat.CFrame = CN(seat.Position,Pos)
  80. seatb.CFrame = seat.CFrame*CN(0,1.25,1.25)*CA(MR(15),0,0)
  81. seatattachment.CFrame=seatb.CFrame*CN(0,0,2)*CA(MR(90),0,0)
  82. seatatball1.CFrame=seatattachment.CFrame*CN(0,2,0)
  83. seatattachment2.CFrame=seatatball1.CFrame*CN(0,-1,-2)*CA(MR(65),0,0)
  84. seatatball2.CFrame=seatattachment2.CFrame*CN(0,-2.5,0)
  85. seatattachment3.CFrame=seatatball2.CFrame*CN(0,-1,2.5)*CA(MR(-65),0,0)
  86. seatatball3.CFrame=seatattachment3.CFrame*CN(0,-2.5,0)
  87. seatattachment4.CFrame=seatatball3.CFrame*CN(0,-.5,2.5)*CA(MR(-80),0,0)
  88. Ball.CFrame=seatattachment4.CFrame*CN(0,-2,0)
  89. handp.CFrame=Ball.CFrame*CN(0,0.5,0.75)*ca(rd(65),0,0)
  90. Handle.CFrame=handp.CFrame*CN(0,1,0)*CA(0,0,MR(90))
  91. Barrel.CFrame=seat.CFrame*CN(0,2,-5.25)*CA(MR(90),0,0)
  92. pit.CFrame=Barrel.CFrame*CN(0,-2.01,0)
  93. end
  94. q = function(f) CR(CC(function() f() end)) end
  95. qi = function(ttz) local qii = it(ttz[1],ttz[2]) table.foreach(ttz,function(oi,oi2) if oi ~= 1 and oi ~= 2 then qii[oi] = oi2 end end) return qii end
  96. DetectSurface = function(pos, part) local surface = nil local pospos = part.CFrame local pos2 = pospos:pointToObjectSpace(pos) local siz = part.Size local shaep = part.Shape if shaep == Enum.PartType.Ball or shaep == Enum.PartType.Cylinder then surface = {"Anything", CN(pospos.p, pos)*CN(0, 0, -(pospos.p - pos).magnitude+0.12)*CA(MR(-90), 0, 0)} elseif pos2.Y > ((siz.Y/2)-0.01) then surface = {"Top", CA(0, 0, 0)} elseif pos2.Y < -((siz.Y/2)-0.01) then surface = {"Bottom", CA(-math.pi, 0, 0)} elseif pos2.X > ((siz.X/2)-0.01) then surface = {"Right", CA(0, 0, MR(-90))} elseif pos2.X < -((siz.X/2)-0.01) then surface = {"Left", CA(0, 0, MR(90))} elseif pos2.Z > ((siz.Z/2)-0.01) then surface = {"Back", CA(MR(90), 0, 0)} elseif pos2.Z < -((siz.Z/2)-0.01) then surface = {"Front", CA(MR(-90), 0, 0)} end return surface end
  97. function Trail(ob,times,waitz,col,thickz,ofz)
  98. q(function()
  99. local oldpos=(ob.CFrame *ofz).p
  100. for i=1,times do
  101. local obp=(ob.CFrame *ofz).p
  102. local mag=(oldpos - obp).magnitude
  103. local tr=Part(ob,false,false,0.5,0.15,BN("White"),v3(0,0,0),"Plastic") tr.Name="Trail"
  104. tr.Anchored=true
  105. tr.CFrame=cn(oldpos,obp)
  106. tr.CFrame=tr.CFrame + tr.CFrame.lookVector* (mag/2)
  107. local trm=it("CylinderMesh",tr)
  108. trm.Scale=v3(5*thickz,mag*5,5*thickz)
  109. q(function()
  110. for i=5*thickz,0,-5*thickz/10 do
  111. trm.Scale=v3(i,mag*5,i) wait()
  112. end
  113. tr:Remove''
  114. end)
  115. tr.CFrame=tr.CFrame *ca(rd(90),0,0)
  116. oldpos=obp wait(waitz)
  117. end
  118. end)
  119. end
  120. TurretShot = function(offset)
  121. q(function()
  122. local muzzle=Part(mod,true,true,0,0,BN(Colors[math.random(1,#Colors)]),V3(1,1,1),"Plastic")
  123. local muzm=it("SpecialMesh",muzzle) muzm.MeshId=Crown muzzle.CFrame=pit.CFrame*cn(0,-1,-0.25)*ca(0,0,rd(180)) muzm.Scale=v3(1.25,2,1.25)
  124. for i=0,1,0.1 do muzzle.CFrame=pit.CFrame*cn(0,-1-(i/2),-0.25)*ca(0,0,rd(180)) muzzle.Transparency=i muzm.Scale=v3(1+i*0.75,2-i*0.25,1+i*0.75) wait() end muzzle:Remove()
  125. end)
  126. q(function()
  127. local speed = 5
  128. local bb = Part(mod,true,true,0,0,BN("Really black"),V3(0.6,1.5,0.6),"Plastic","Cylinder")
  129. bb.CFrame = offset*CN(0,2.8+(MRA(0,30)/10),0) q(function() bb2=bb:Clone() bb2.Parent=workspace.CurrentCamera while wait() do pcall(function() bb2.CFrame=bb.CFrame end) end end)
  130. wait() --workspace.CurrentCamera.CameraSubject=bb
  131. Trail(bb,100,0,BN("White"),1,CN(0,0,0))
  132. for i=1,math.huge do
  133. bb.CFrame=bb.CFrame*CN(0,speed,0)*CA(MR(-0.2),0,0) -- try putting this before bhit and bpos
  134. bhit,bpos=ray(bb.Position,bb.Position - (bb.CFrame *CN(0,-1,0)).p)
  135. if bhit and bpos and (bpos - bb.Position).magnitude < speed and bhit.Name~="Trail" and bhit.Name~="Blast" then
  136. break
  137. end
  138. wait()
  139. end
  140. Search(Workspace, bb, 10) Blast("Black",bb.CFrame*cn(0,0,1)*ca(rd(90),0,0)) RocketExplode:Play()
  141. if bhit.Name~="Base" and not bhit.Parent:FindFirstChild("Humanoid") then
  142. bhit.Anchored = false bhit:BreakJoints()
  143. local bpp = qi({"BodyVelocity",bhit,maxForce=v3(1/0,1/0,1/0),velocity=cn(me.Character.Torso.Position,bhit.Position+v3(0,7.5,0)).lookVector*80}) wait(0.2) bpp:Remove()
  144. end
  145. bb.Anchored = false
  146. if bhit ~= bb and bhit.Name~="Trail" and bhit.Name ~="Blast" then
  147. stick(bb,bhit)
  148. end
  149. q(function() wait(3) bb:Remove() end)
  150. end)
  151. end
  152.  
  153. if script.Parent.className ~= "HopperBin" then h = Instance.new("HopperBin",me.Backpack) h.Name = "Turret" end
  154. Shoot = function() TurretShot(Barrel.CFrame*CA(MR(180),0,0)) end
  155. TurretFace(V3(0,1,10))
  156. h.Selected:connect(function(Mouse) canfire=true Sitting=true
  157. q(function()
  158. while wait() do
  159. TurretFace(Mouse.Hit.p)
  160. end
  161. end)
  162. q(function()
  163. while Sitting==true do
  164. me.Character.Humanoid.Sit = true
  165. me.Character.Torso.Anchored = true
  166. me.Character.Torso.CFrame = seat.CFrame*CN(0,1.75,0.5) wait()
  167. end
  168. end)
  169. Mouse.Button1Down:connect(function()
  170. if canfire==true and Sitting==true then
  171. canfire=false
  172. Fiyah:Play()
  173. Shoot()
  174. wait(0.5)
  175. canfire=true
  176. end
  177. end)
  178. end)
  179. h.Deselected:connect(function() Sitting=false canfire=false me.Character.Torso.Anchored=false me.Character.Humanoid.Sit=false end)
  180. me.Character.Humanoid.Died:connect(function(l) for i,v in pairs(cam:children()) do v:Remove() end end)
  181. --TigerBloodd
Add Comment
Please, Sign In to add comment