Guest User

Untitled

a guest
Jan 8th, 2022
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.42 KB | None | 0 0
  1. wait(1)
  2. local ContentProvider = Game:GetService("ContentProvider")
  3. local Tool = script.Parent;
  4. local pewsound
  5. local pewsound2
  6. local bangsound
  7. local bangsound2
  8. local cam
  9. local ggui
  10. local lon = false
  11. enabled = true
  12. automatichold = false
  13. dmged = false
  14. shotgun = false
  15. equipped = false
  16. overheated = false
  17. isZoom = false
  18. MaxDist = 1000
  19. local mouseicons = {70288578, 70288572, 70288578}
  20. local metalhit = {154441338, 154441342, 154441355}
  21. local FireTrack = script.Parent.Fire
  22. local ReloadTrack = script.Parent.Reload
  23. local Idle = script.Parent.Idle
  24.  
  25. cam = game.Workspace.CurrentCamera
  26. -----------------------------------------ONLY EDIT THESE VALUES!!!!!-----------------------------------------
  27. -----!Instructions!-----
  28. --Make sure you have a part in the gun named Barrel, it is where the raycast will shoot from.--
  29. --Just place this script into any gun and edit the values below.--
  30. --Editting anything else will risk breaking it.--
  31. ------------------------
  32. local function LoadAssets(AssetList)
  33. -- Takes an asset list and preloads it. Will not wait for them to load.
  34.  
  35. for _, AssetId in pairs(AssetList) do
  36. ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. AssetId)
  37. end
  38. end
  39.  
  40. LoadAssets({144884872, 2434541, 5133543, 2423433, 41143243, 2453865, 21433365, 2154549})
  41. ------------------------
  42. Damage = 29
  43. SPS = 15 -- Shots Per Second, gives a limit of how fast the gun shoots.
  44. Recoil = 4 -- [1-10] [1 = Minigun, 10 = Sniper]
  45. WallShoot = false -- Shoots through walls.
  46. GH = false -- [True = RB can't hurt RB.] [False = RB can hurt RB.]
  47. BulletColor = "Cool yellow" -- Any Brickcolor will work.
  48. Flash = true
  49. --------------------------------------------------------------------------------------------------------
  50.  
  51. local zm = Instance.new("Part")
  52. zm.Name = "ZoomZM"
  53. zm.Anchored = true
  54. zm.Transparency = 1
  55. zm.Size = Vector3.new(1,1,1)
  56. zm.CanCollide = false
  57. GunType = 0
  58. GroupID = 9999
  59. function recoiltool1()
  60. script.Parent.GripForward = Vector3.new(-0.208, -0.091, -0.974)
  61. script.Parent.GripPos = Vector3.new(0.018, -0.37, 0.271)
  62. script.Parent.GripRight = Vector3.new(0.978, -0.018, -0.207)
  63. script.Parent.GripUp = Vector3.new(-0.001, 0.996, -0.093)
  64. ----------
  65. end
  66. function AntiGH(char1,char2)
  67. if GH then
  68. local plyr1 = game.Players:findFirstChild(char1.Name)
  69. local plyr2 = game.Players:findFirstChild(char2.Name)
  70. if plyr1 and plyr2 then
  71. if plyr1:IsInGroup(GroupID) and plyr2:IsInGroup(GroupID) then
  72. return false
  73. end
  74. end
  75. return true
  76. elseif not GH then
  77. return true
  78. end
  79. end
  80. function RayCast(Start,End,Ignore)
  81. if WallShoot then
  82. ray1 = Ray.new(Start, End.unit * 999.999)
  83. local Part1, TempPos = Workspace:FindPartOnRay(ray1,Ignore)
  84. ray2 = Ray.new(TempPos, End.unit * 999.999)
  85. local Part2, EndPos = Workspace:FindPartOnRay(ray2,Part1)
  86. return Part1, Part2, EndPos
  87. elseif not WallShoot then
  88. ray = Ray.new(Start, End.unit * 999.999)
  89. return Workspace:FindPartOnRay(ray,Ignore)
  90. end
  91. end
  92.  
  93. function getty(hitted)
  94. local IDMH = metalhit[math.random(1,#metalhit)]
  95. if hitted:IsA("BasePart") and hitted.Name == "Metal" then
  96. local mhs = Instance.new("Sound")
  97. mhs.SoundId = "http://www.roblox.com/asset?id=" .. IDMH
  98. mhs.Volume = 0.4
  99. mhs.Parent = hitted
  100. mhs:Play()
  101. game:GetService('Debris'):AddItem(mhs, 1)
  102. end
  103.  
  104. if hitted:IsA("BasePart") and hitted.Name == "Glass" or hitted.Name == "Window" or hitted.Name == "DestructionPart" and hitted.Transparency > 0 then
  105. local gbs = Instance.new("Sound")
  106. gbs.SoundId = "http://www.roblox.com/asset/?id=144884907"
  107. gbs.Volume = 0.5
  108. gbs.Parent = hitted
  109. gbs:Play()
  110. game:GetService('Debris'):AddItem(gbs, 1)
  111. hitted:Destroy()
  112. end
  113.  
  114. if hitted:IsA("BasePart") and hitted.Name == "Wheel" or hitted.Name == "Tire" then
  115. local tps = Instance.new("Sound")
  116. tps.SoundId = "http://www.roblox.com/asset/?id=160248280"
  117. tps.Volume = 0.5
  118. tps.Parent = hitted
  119. tps:Play()
  120. hitted.CanCollide = false
  121. game:GetService('Debris'):AddItem(tps, 1)
  122. end
  123.  
  124. if hitted:IsA("BasePart") and hitted.Name == "Head" then
  125. local bhs = Instance.new("Sound")
  126. bhs.SoundId = "http://www.roblox.com/asset/?id=144884872"
  127. bhs.Volume = 0.6
  128. bhs.Pitch = math.random(90,110)/100
  129. bhs.Parent = hitted
  130. bhs:Play()
  131. local bhe = Instance.new("Fire")
  132. bhe.Color = BrickColor.new("Really red").Color
  133. bhe.SecondaryColor = BrickColor.new("Really red").Color
  134. bhe.Heat = 0
  135. bhe.Size = 4
  136. bhe.Name = "BloodEfect"
  137. bhe.Parent = hitted
  138. game:GetService('Debris'):AddItem(bhe, 0.6)
  139. game:GetService('Debris'):AddItem(bhs, 1)
  140. end
  141. end
  142.  
  143. function DmgPlr(Part)
  144. if Part ~= nil then
  145. local c = Instance.new("ObjectValue")
  146. c.Name = "creator"
  147. c.Value = game.Players:findFirstChild(script.Parent.Parent.Name)
  148. local hum = Part.Parent:findFirstChild("Humanoid")
  149. local hathum = Part.Parent.Parent:findFirstChild("Humanoid")
  150. local hat = Part.Parent
  151. getty(Part)
  152. if hathum ~= nil and hat:IsA("Hat") and AntiGH(hathum.Parent, script.Parent.Parent) then
  153. hathum:TakeDamage(Damage/1)
  154. Part.Parent = game.Workspace
  155. Part:BreakJoints()
  156. --Part.CFrame = CFrame.new(Part.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)))
  157. hat:Remove()
  158. c.Parent = hathum
  159. game.Debris:AddItem(c,1.5)
  160. elseif hum ~= nil and AntiGH(hum.Parent, script.Parent.Parent) then
  161. if Part.Name == "Head" then
  162. hum:TakeDamage(Damage*3)
  163. end
  164. hum:TakeDamage(Damage)
  165. c.Parent = hum
  166. game.Debris:AddItem(c,1.5)
  167. end
  168. end
  169. end
  170.  
  171. function onButton1Down(mouse)
  172. FireTrack:Play()
  173. if script.Parent.Ammo.Value == 0 then
  174. else
  175. if GunType == 0 then
  176. if (not enabled) then return end
  177. enabled = false
  178. mouse.Icon = "http://www.roblox.com/asset/?id=".. mouseicons[math.random(1,3)]-- WIP151
  179. local cam_rot = cam.CoordinateFrame - cam.CoordinateFrame.p
  180. local cam_scroll = (cam.CoordinateFrame.p - cam.Focus.p).magnitude
  181. local ncf = CFrame.new(cam.Focus.p)*cam_rot*CFrame.fromEulerAnglesXYZ(0.003, 0.004, 0)
  182. cam.CoordinateFrame = ncf*CFrame.new(0, 0, cam_scroll)
  183. --WPN_UP
  184. LaserShoot(mouse)
  185. if Flash then
  186. script.Parent.Barrel.Light.Light.Visible = true
  187. script.Parent.Barrel.PointLight.Enabled = true
  188. script.Parent.Barrel.Smoke.Enabled = true
  189.  
  190. end
  191. script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
  192. wait(0.01)
  193. if Flash then
  194. script.Parent.Barrel.Light.Light.Visible = false
  195. script.Parent.Barrel.PointLight.Enabled = false
  196. script.Parent.Barrel.Smoke.Enabled = false
  197. end
  198. wait(1/SPS)
  199. --WPN_DOWN
  200. mouse.Icon = "http://www.roblox.com/asset/?id=70288585"
  201. enabled = true
  202. elseif GunType == 1 then
  203. automatichold = true
  204. while automatichold == true and script.Parent.Ammo.Value ~= 0 do wait()
  205. if (not enabled) then return end
  206. if script.Parent.Parent:findFirstChild("Humanoid").Health == 0 then script.Parent:Remove() end
  207. enabled = false
  208. mouse.Icon = "http://www.roblox.com/asset/?id=".. mouseicons[math.random(1,3)]-- WIP151
  209. local cam_rot = cam.CoordinateFrame - cam.CoordinateFrame.p
  210. local cam_scroll = (cam.CoordinateFrame.p - cam.Focus.p).magnitude
  211. local ncf = CFrame.new(cam.Focus.p)*cam_rot*CFrame.fromEulerAnglesXYZ(0.005, 0.003, 0)
  212. cam.CoordinateFrame = ncf*CFrame.new(0, 0, cam_scroll)
  213. LaserShoot(mouse)
  214. if Flash then
  215. script.Parent.Barrel.Light.Light.Visible = true
  216. end
  217. script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
  218. wait(0.01)
  219. if Flash then
  220. script.Parent.Barrel.Light.Light.Visible = false
  221. end
  222. wait(1/SPS)
  223. mouse.Icon = "http://www.roblox.com/asset/?id=70288585"
  224. --WPN_DOWN
  225. enabled = true
  226. end
  227. end
  228. end
  229. end
  230.  
  231. function LaserShoot(mouse)
  232. hit = mouse.Hit.p
  233. local StartPos = script.Parent.Barrel.CFrame.p
  234. local rv = (StartPos-hit).magnitude/(Recoil * 20)
  235. local rcl = Vector3.new(math.random(-rv,rv),math.random(-rv,rv),math.random(-rv,rv))
  236. aim = hit + rcl
  237. local P = Instance.new("Part")
  238. P.Name = "Bullet"
  239. P.formFactor = 3
  240. P.BrickColor = BrickColor.new(BulletColor)
  241. P.Size = Vector3.new(1,1,1)
  242. P.Anchored = true
  243. P.CanCollide = false
  244. P.Transparency = 1
  245. P.Parent = script.Parent.Parent
  246. local m = Instance.new("CylinderMesh")
  247. m.Name = "Mesh"
  248. m.Parent = P
  249. local c = Instance.new("ObjectValue")
  250. c.Name = "creator"
  251. c.Value = game.Players:findFirstChild(script.Parent.Parent.Name)
  252. pewsound = script.Parent.Handle:FindFirstChild("Fire")
  253. if pewsound then
  254. pewsound.Pitch = math.random(90,110)/100
  255. pewsound:Play()
  256. end --Brick created. Moving on to next part
  257. local SPos = script.Parent.Barrel.CFrame.p
  258. if WallShoot then
  259. local Part1, Part2, EndPos = RayCast(SPos, (aim-SPos).unit * 999, script.Parent.Parent)
  260. DmgPlr(Part1)
  261. DmgPlr(Part2)
  262. if Part1 and Part2 then
  263. local enddist = (EndPos-SPos).magnitude
  264. P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0,0,-enddist/2) * CFrame.Angles(math.rad(90),0,0)
  265. m.Scale = Vector3.new(.04,enddist,.04)
  266. else
  267. P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0,0,-MaxDist/2) * CFrame.Angles(math.rad(90),0,0)
  268. m.Scale = Vector3.new(.04,MaxDist,.04)
  269. end
  270. elseif not WallShoot then
  271. local Part, Pos = RayCast(SPos, (aim-SPos).unit * 999, script.Parent.Parent)
  272. DmgPlr(Part)
  273. if Part then
  274. local dist = (Pos-SPos).magnitude
  275. P.CFrame = CFrame.new(Pos, SPos) * CFrame.new(0,0,-dist/2) * CFrame.Angles(math.rad(90),0,0)
  276. m.Scale = Vector3.new(.1,dist,.1)
  277. else
  278. P.CFrame = CFrame.new(Pos, SPos) * CFrame.new(0,0,-MaxDist/2) * CFrame.Angles(math.rad(90),0,0)
  279. m.Scale = Vector3.new(.1,MaxDist,.1)
  280. end
  281. end
  282. game.Debris:AddItem(P,.1)
  283. end
  284.  
  285. function onButton1Up(mouse)
  286. automatichold = false
  287. end
  288.  
  289. function onKeyDown(key, mouse)
  290.  
  291. if key:lower() == "r" then
  292. if script.Parent.Ammo.Value ~= script.Parent.MaxAmmo.Value then
  293. reloadsound = script.Parent.Handle:FindFirstChild("Reload")
  294. if reloadsound then
  295. script.Parent.Reload:Play()
  296. reloadsound:Play()
  297. end
  298. enabled = false
  299. script.Parent.VisibleB.Value = true
  300. script.Parent.StringValue.Value = "Reloading"
  301. mouse.Icon = "http://www.roblox.com/asset/?id=70288599"
  302. script.Parent.Handle.RLD:play()
  303. repeat script.Parent.StringValue.Value = "Reloading" wait(0.3) script.Parent.Ammo.Value = script.Parent.Ammo.Value + 3 script.Parent.StringValue.Value = "Reloading" until script.Parent.Ammo.Value >= script.Parent.MaxAmmo.Value
  304. script.Parent.Ammo.Value = script.Parent.MaxAmmo.Value
  305. wait(0.2)
  306. script.Parent.VisibleB.Value = false
  307. enabled = true
  308. mouse.Icon = "http://www.roblox.com/asset/?id=70288585"
  309. end
  310. end
  311.  
  312. if key:lower() == "l" then
  313. lon = not lon
  314. script.Parent.FLight.Sound:Play()
  315. if lon == true then
  316. script.Parent.FLight.Light.Enabled = true
  317. script.Parent.FLight.SpotLight.Enabled = true
  318. elseif lon == false then
  319. script.Parent.FLight.Light.Enabled = false
  320. script.Parent.FLight.SpotLight.Enabled = false
  321. end
  322. end
  323.  
  324. end
  325.  
  326. function onEquipped(mouse)
  327. equipped = true
  328. script.Parent.Handle.Out1:Play()
  329.  
  330. if mouse == nil then
  331. print("Mouse not found")
  332. return
  333. end
  334. mouse.Icon = "http://www.roblox.com/asset/?id=70288585"
  335. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  336. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  337. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  338.  
  339. end
  340. function onUnequipped(mouse)
  341. equipped = false
  342. script.Parent.Handle.In1:Play()
  343. script.Parent.Handle.In2:Play()
  344. automatichold = false
  345. end
  346. script.Parent.Equipped:connect(onEquipped)
  347. script.Parent.Unequipped:connect(onUnequipped)
  348. while true do wait()
  349. if script.Parent.Ammo.Value == 0 then
  350. script.Parent.VisibleB.Value = true
  351. script.Parent.StringValue.Value = "Reload"
  352. end
  353. if GunType == 1 then
  354. script.Parent.ModeText.Value = "Auto"
  355. else
  356. script.Parent.ModeText.Value = "Semi"
  357. end
  358. end
Advertisement
Add Comment
Please, Sign In to add comment