MrWiggles1029

ROBLOX Gun Turrent

Sep 4th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.60 KB | None | 0 0
  1. plr=game.Players.LocalPlayer
  2. char=plr.Character
  3. color="Cyan"
  4. BaseColor="Bright blue"
  5. FireRate=.5
  6. sound=Instance.new("Sound",char.Head)
  7. sound.Pitch=1
  8. sound.Volume=.3
  9. sound.SoundId="http://www.roblox.com/asset/?id=2920959"
  10. sound2=Instance.new("Sound",char.Head)
  11. sound2.Pitch=1.8
  12. sound2.Volume=.2
  13. sound2.SoundId="http://www.roblox.com/asset?id=2248511"
  14. mode="Normal"
  15. Speed=80
  16. pcall(function() char["Parts>Etc"]:Remove() end)
  17. function makepart(parent,name,t,r,anc,can,s1,s2,s3,col)
  18. p=Instance.new("Part",parent)
  19. p.formFactor="Custom"
  20. p.TopSurface="Smooth"
  21. p.BottomSurface="Smooth"
  22. p.Name=name
  23. p.Transparency=t
  24. p.Reflectance=r
  25. p.Anchored=anc
  26. p.BrickColor=BrickColor.new(col)
  27. p.CanCollide=can
  28. p.Size=Vector3.new(s1,s2,s3)
  29. return p
  30. end
  31. --[[Parts]]--
  32. main=Instance.new("Model",char)
  33. main.Name="Parts>Etc"
  34. mpart=makepart(main,"MainPart",0,0,false,false,1,1,1,BaseColor)
  35. smesh=Instance.new("SpecialMesh",mpart)
  36. smesh.MeshType="Sphere"
  37. smesh.Scale=Vector3.new(1.5,1.4,1)
  38. w1=Instance.new("Weld",mpart)
  39. w1.Part0=mpart
  40. w1.Part1=char.Torso
  41. w1.C1=CFrame.new(0,0.2,.6)
  42. w1.C0=CFrame.new(0,0,0)
  43. part2=makepart(main,"P2",0,0,false,false,1,1,1,color)
  44. smesh2=Instance.new("SpecialMesh",part2)
  45. smesh2.MeshType="Sphere"
  46. smesh2.Scale=Vector3.new(1,1,1)
  47. w2=Instance.new("Weld",mpart)
  48. w2.Part0=part2
  49. w2.Part1=mpart
  50. w2.C1=CFrame.new(0,0,.2)
  51. w2.C0=CFrame.new(0,0,0)
  52. part3=makepart(main,"P3",0,0,false,false,1,1,1,BaseColor)
  53. cmesh=Instance.new("CylinderMesh",part3)
  54. cmesh.Scale=Vector3.new(.2,2,.2)
  55. w3=Instance.new("Weld",mpart)
  56. w3.Part0=part3
  57. w3.Part1=mpart
  58. w3.C1=CFrame.Angles(0,0,-0.8)
  59. w3.C0=CFrame.new(0,-1,0)
  60. part4=makepart(main,"P4",0,0,false,false,1,1,1,BaseColor)
  61. cmesh=Instance.new("CylinderMesh",part4)
  62. cmesh.Scale=Vector3.new(.2,2,.2)
  63. w4=Instance.new("Weld",mpart)
  64. w4.Part0=part4
  65. w4.Part1=mpart
  66. w4.C1=CFrame.Angles(0,0,0.8)
  67. w4.C0=CFrame.new(0,-1,0)
  68. part5=makepart(main,"P5",0,0,false,false,1,1,1,color)
  69. smesh5=Instance.new("SpecialMesh",part5)
  70. smesh5.MeshType="Sphere"
  71. smesh5.Scale=Vector3.new(.5,.5,.5)
  72. w5=Instance.new("Weld",mpart)
  73. w5.Part0=part5
  74. w5.Part1=part4
  75. w5.C1=CFrame.new(0,1,0)
  76. w5.C0=CFrame.Angles(0,0,0)
  77. part6=makepart(main,"P6",0,0,false,false,1,1,1,color)
  78. smesh6=Instance.new("SpecialMesh",part6)
  79. smesh6.MeshType="Sphere"
  80. smesh6.Scale=Vector3.new(.5,.5,.5)
  81. w6=Instance.new("Weld",mpart)
  82. w6.Part0=part6
  83. w6.Part1=part3
  84. w6.C1=CFrame.new(0,1.2,0)
  85. w6.C0=CFrame.Angles(0,0,0)
  86. part7=makepart(main,"P7",0,0,false,false,1,1,1,BaseColor)
  87. smesh7=Instance.new("CylinderMesh",part7)
  88. smesh7.Scale=Vector3.new(.2,1,.2)
  89. w7=Instance.new("Weld",mpart)
  90. w7.Part0=part7
  91. w7.Part1=part6
  92. w7.C1=CFrame.new(0,0,-0.5)
  93. w7.C0=CFrame.Angles(1.5,0,1)
  94. part8=makepart(main,"P8",0,0,false,false,1,1,1,BaseColor)
  95. smesh8=Instance.new("CylinderMesh",part8)
  96. smesh8.Scale=Vector3.new(.2,1,.2)
  97. w8=Instance.new("Weld",mpart)
  98. w8.Part0=part8
  99. w8.Part1=part5
  100. w8.C1=CFrame.new(0,0,-0.5)
  101. w8.C0=CFrame.Angles(1.5,0,1)
  102. part9=makepart(main,"P9",0,0,false,false,1,1,1,"Really black")
  103. smesh9=Instance.new("CylinderMesh",part9)
  104. smesh9.Scale=Vector3.new(.17,.05,.17)
  105. w9=Instance.new("Weld",mpart)
  106. w9.Part0=part9
  107. w9.Part1=part8
  108. w9.C1=CFrame.new(0,0.5,0)
  109. w9.C0=CFrame.Angles(0,0,0)
  110. part10=makepart(main,"P10",0,0,false,false,1,1,1,"Really black")
  111. smesh10=Instance.new("CylinderMesh",part10)
  112. smesh10.Scale=Vector3.new(.16,.05,.16)
  113. w10=Instance.new("Weld",mpart)
  114. w10.Part0=part10
  115. w10.Part1=part7
  116. w10.C1=CFrame.new(0,.5,0)
  117. w10.C0=CFrame.Angles(0,0,0)
  118. part11=makepart(main,"P11",0,0,false,false,1,1,1,BaseColor)
  119. smesh11=Instance.new("CylinderMesh",part11)
  120. smesh11.Scale=Vector3.new(.8,.6,1.1)
  121. w11=Instance.new("Weld",mpart)
  122. w11.Part0=part11
  123. w11.Part1=mpart
  124. w11.C1=CFrame.new(0,-.8,0)
  125. w11.C0=CFrame.Angles(0,0,0)
  126. --[[Tools/Mouse]]--
  127. bin=Instance.new("HopperBin",plr.Backpack)
  128. bin.Name="Gun Turret"
  129. script.Parent=bin
  130. hold=false
  131. effects=false
  132. bin.Selected:connect(function(mouse)
  133. print("Selected")
  134. mouse.Button1Down:connect(function()
  135. if mode=="Normal" then
  136. hold=true
  137. while hold do
  138. local ray = Ray.new(part10.CFrame.p, (mouse.Hit.p - part10.CFrame.p).unit*300)
  139. local hit, position = game.Workspace:FindPartOnRay(ray, char)
  140. local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
  141. if humanoid then
  142. humanoid:TakeDamage(math.random(5,10))
  143. end
  144. local distance = (position - part10.CFrame.p).magnitude
  145. local rayPart = Instance.new("Part", char)
  146. rayPart.Name = "RayPart"
  147. rayPart.BrickColor = BrickColor.new(color)
  148. rayPart.Transparency = 0
  149. rayPart.Anchored = true
  150. rayPart.CanCollide = false
  151. rayPart.TopSurface = Enum.SurfaceType.Smooth
  152. rayPart.BottomSurface = Enum.SurfaceType.Smooth
  153. rayPart.formFactor = Enum.FormFactor.Custom
  154. rayPart.Size = Vector3.new(0.1, 0.1, distance)
  155. rayPart.CFrame = CFrame.new(position, part10.CFrame.p) * CFrame.new(0, 0, -distance/2)
  156. bm=Instance.new("BlockMesh",rayPart)
  157. bm.Scale=Vector3.new(0.2,0.2,1)
  158. game.Debris:AddItem(rayPart, 0.1)
  159. local ray2 = Ray.new(part9.CFrame.p, (mouse.Hit.p - part9.CFrame.p).unit*300)
  160. local hit2, position2 = game.Workspace:FindPartOnRay(ray2, char)
  161. local humanoid2 = hit2 and hit2.Parent and hit2.Parent:FindFirstChild("Humanoid")
  162. if humanoid2 then
  163. humanoid2:TakeDamage(math.random(5,10))
  164. end
  165. local distance2 = (position2 - part9.CFrame.p).magnitude
  166. local rayPart2 = Instance.new("Part", char)
  167. rayPart2.Name = "RayPart"
  168. rayPart2.BrickColor = BrickColor.new(color)
  169. rayPart2.Transparency = 0
  170. rayPart2.Anchored = true
  171. rayPart2.CanCollide = false
  172. rayPart2.TopSurface = Enum.SurfaceType.Smooth
  173. rayPart2.BottomSurface = Enum.SurfaceType.Smooth
  174. rayPart2.formFactor = Enum.FormFactor.Custom
  175. rayPart2.Size = Vector3.new(0.1, 0.1, distance2)
  176. rayPart2.CFrame = CFrame.new(position2, part9.CFrame.p) * CFrame.new(0, 0, -distance2/2)
  177. bm2=Instance.new("BlockMesh",rayPart2)
  178. bm2.Scale=Vector3.new(0.2,0.2,1)
  179. game.Debris:AddItem(rayPart2, 0.1)
  180. sound:Play()
  181. wait(FireRate)
  182. end
  183. end
  184. if mode=="Fly" then
  185. hold=true
  186. pcall(function() char.Head.BV:Destroy() end)
  187. pcall(function() char.Torso.BG:Destroy() end)
  188. local bv = Instance.new("BodyVelocity")
  189. bv.Parent = char.Head
  190. bv.Name="BV"
  191. bv.maxForce = Vector3.new(1e+010, 1e+010, 1e+010)
  192. bg = Instance.new("BodyGyro")
  193. bg.maxTorque = Vector3.new(0,0,0)
  194. bg.Parent = char.Torso
  195. bg.Name="BG"
  196. bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  197. char.Torso["Right Shoulder"].DesiredAngle = -6
  198. char.Torso["Left Shoulder"].DesiredAngle = -6
  199. for i=1,5 do
  200. fire=Instance.new("Fire",part11)
  201. fire.Heat=50
  202. fire.Size=3
  203. fire.Color=BrickColor.new(color).Color
  204. fire.SecondaryColor=BrickColor.new(color).Color
  205. fire.Name="F"
  206. end
  207. effects=true
  208. while hold do
  209. wait()
  210. bg.cframe = CFrame.new(char.Torso.Position,mouse.hit.p) * CFrame.fromEulerAnglesXYZ(math.rad(-90),0,0)
  211. bv.velocity = (char.Head.Position - mouse.Hit.p).unit * -Speed
  212. bg.cframe = CFrame.new(char.Torso.Position,mouse.hit.p) * CFrame.fromEulerAnglesXYZ(math.rad(-90),0,0)
  213. end
  214. end
  215. if mode=="Explode" then
  216. hold=true
  217. while hold do
  218. wait()
  219. local ray = Ray.new(part10.CFrame.p, (mouse.Hit.p - part10.CFrame.p).unit*300)
  220. local hit, position = game.Workspace:FindPartOnRay(ray, char)
  221. local distance = (position - part10.CFrame.p).magnitude
  222. local rayPart = Instance.new("Part", char)
  223. rayPart.Name = "RayPart"
  224. rayPart.BrickColor = BrickColor.new("Bright yellow")
  225. rayPart.Transparency = 0
  226. rayPart.Anchored = true
  227. rayPart.CanCollide = false
  228. rayPart.TopSurface = Enum.SurfaceType.Smooth
  229. rayPart.BottomSurface = Enum.SurfaceType.Smooth
  230. rayPart.formFactor = Enum.FormFactor.Custom
  231. rayPart.Size = Vector3.new(0.4, 0.4, distance)
  232. rayPart.CFrame = CFrame.new(position, part10.CFrame.p) * CFrame.new(0, 0, -distance/2)
  233. bm=Instance.new("BlockMesh",rayPart)
  234. bm.Scale=Vector3.new(0.2,0.2,1)
  235. game.Debris:AddItem(rayPart, 0.1)
  236. local ray2 = Ray.new(part9.CFrame.p, (mouse.Hit.p - part9.CFrame.p).unit*300)
  237. local hit2, position2 = game.Workspace:FindPartOnRay(ray2, char)
  238. local distance2 = (position2 - part9.CFrame.p).magnitude
  239. local rayPart2 = Instance.new("Part", char)
  240. rayPart2.Name = "RayPart"
  241. rayPart2.BrickColor = BrickColor.new("Bright yellow")
  242. rayPart2.Transparency = 0
  243. rayPart2.Anchored = true
  244. rayPart2.CanCollide = false
  245. rayPart2.TopSurface = Enum.SurfaceType.Smooth
  246. rayPart2.BottomSurface = Enum.SurfaceType.Smooth
  247. rayPart2.formFactor = Enum.FormFactor.Custom
  248. rayPart2.Size = Vector3.new(0.4, 0.4, distance2)
  249. rayPart2.CFrame = CFrame.new(position2, part9.CFrame.p) * CFrame.new(0, 0, -distance2/2)
  250. bm2=Instance.new("BlockMesh",rayPart2)
  251. bm2.Scale=Vector3.new(0.2,0.2,1)
  252. ex=Instance.new("Explosion",workspace)
  253. ex.Position=position
  254. sound2:Play()
  255. game.Debris:AddItem(rayPart2, 0.1)
  256. wait(1)
  257. end
  258. end
  259. end)
  260. mouse.KeyDown:connect(function(key)
  261. if key=="q" then
  262. bin.Name="Gun Turret"
  263. mode="Normal"
  264. elseif key=="e" then
  265. bin.Name="Fly"
  266. mode="Fly"
  267. elseif key=="r" then
  268. bin.Name="Gun Turret[E]"
  269. mode="Explode"
  270. end
  271. end)
  272. mouse.Button1Up:connect(function()
  273. hold=false
  274. effects=false
  275. for i=1,10 do
  276. pcall(function() char.Head.BV:Destroy() end)
  277. pcall(function() char.Torso.BG:Destroy() end)
  278. pcall(function() part11.F:Remove() end)
  279. end
  280. end)
  281. end)
  282. plr=game.Players.NoobMaster936
  283. char=plr.Character
  284. rarm=char["Right Arm"]
  285. Acol="Navy blue"
  286. function weld(name,parent,p1,p0,c1,c0)
  287. we=Instance.new("Weld",parent)
  288. we.Part1=p1
  289. we.Part0=p0
  290. we.C1=c1
  291. we.C0=c0
  292. end
  293. function bm(parent)
  294. b=Instance.new("BlockMesh",parent)
  295. end
  296. function me(parent,type,sc1,sc2,sc3)
  297. m=Instance.new("SpecialMesh",parent)
  298. m.MeshType=type
  299. m.Scale=vec(sc1,sc2,sc3)
  300. end
  301. eff=Instance.new("Part",plr.Character)
  302. eff.formFactor="Custom"
  303. eff.BrickColor=BrickColor.new(Acol)
  304. eff.Name="Eff"
  305. eff.Size=Vector3.new(0.01,1.2,0.15)
  306. eff.Anchored=false
  307. eff.CanCollide=false
  308. eff:BreakJoints()
  309. bm(eff)
  310. eff4=Instance.new("Part",plr.Character)
  311. eff4.formFactor="Custom"
  312. eff4.BrickColor=BrickColor.new(Acol)
  313. eff4.Name="Eff4"
  314. eff4.Size=Vector3.new(0.01,1.2,0.15)
  315. eff4.Anchored=false
  316. eff4.CanCollide=false
  317. eff4:BreakJoints()
  318. bm(eff4)
  319. eff3=Instance.new("Part",plr.Character)
  320. eff3.formFactor="Custom"
  321. eff3.BrickColor=BrickColor.new(Acol)
  322. eff3.Name="Eff3"
  323. eff3.Size=Vector3.new(0.01,0.20,0.99)
  324. eff3.Anchored=false
  325. eff3.CanCollide=false
  326. eff3:BreakJoints()
  327. bm(eff3)
  328. weld("EFF1",rarm,eff,rarm,CFrame.Angles(0,0,0),CFrame.new(0.46,0.14,0.29))
  329. weld("EFF2",rarm,eff4,rarm,CFrame.Angles(0,0,0),CFrame.new(0.46,0.14,-0.29))
  330. weld("EFF2",rarm,eff3,rarm,CFrame.Angles(0.99,0,0),CFrame.new(0.46,0,-0.02))
Add Comment
Please, Sign In to add comment