Advertisement
Ilkailka

RPG roblox

Apr 24th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 56.12 KB | None | 0 0
  1.  
  2.  
  3. Player = game.Players.LocalPlayer
  4. Name = "RPG-7"
  5. selected = false
  6. canDual = false
  7. dual = false
  8. Button1Down = false
  9. damage = 100
  10. canFire = true
  11. canFire2 = false
  12. readyTime = 0.5
  13. automatic = true
  14. burst = false
  15. burstCount = 0
  16. burstCountMax = 3
  17. canSilence = false
  18. silenced = false
  19. canZoom = true
  20. zoom = false
  21. switchToSingle = false
  22. switchToBurst = false
  23. switchToAutomatic = false
  24.  
  25.  
  26. ammoGui = Instance.new("ScreenGui")
  27. ammoGui.Name = Name
  28. local frame = Instance.new("Frame")
  29. frame.Name = "Frame"
  30. frame.Size = UDim2.new(0, 165, 0, 60)
  31. frame.Position = UDim2.new(0, 0, 1, -60)
  32. frame.BackgroundColor3 = Color3.new(1, 1, 1)
  33. frame.BorderColor3 = Color3.new(0, 0, 0)
  34. frame.Parent = ammoGui
  35. local label = Instance.new("TextLabel")
  36. label.Name = "Weapon"
  37. label.Text = "Weapon: " ..Name
  38. label.Size = UDim2.new(1, 0, 0, 20)
  39. label.Position = UDim2.new(0, 0, 0, 0)
  40. label.BackgroundColor3 = Color3.new(1, 0, 0)
  41. label.BorderColor3 = Color3.new(0, 0, 0)
  42. label.Parent = frame
  43. local label = Instance.new("TextLabel")
  44. label.Name = "MagazinePrefix"
  45. label.Text = " Magazine:"
  46. label.TextXAlignment = "Left"
  47. label.Size = UDim2.new(1, 0, 0, 20)
  48. label.Position = UDim2.new(0, 0, 0, 20)
  49. label.BackgroundColor3 = Color3.new(1, 1, 1)
  50. label.BorderColor3 = Color3.new(0, 0, 0)
  51. label.Parent = frame
  52. local label = Instance.new("TextLabel")
  53. label.Name = "Magazine"
  54. label.Text = "0/0"
  55. label.TextXAlignment = "Right"
  56. label.Size = UDim2.new(1, 0, 0, 20)
  57. label.Position = UDim2.new(0, -10, 0, 20)
  58. label.BackgroundTransparency = 1
  59. label.BorderSizePixel = 0
  60. label.Parent = frame
  61. local label = Instance.new("TextLabel")
  62. label.Name = "AmmoPrefix"
  63. label.Text = " Ammunition:"
  64. label.TextXAlignment = "Left"
  65. label.Size = UDim2.new(1, 0, 0, 20)
  66. label.Position = UDim2.new(0, 0, 0, 40)
  67. label.BackgroundColor3 = Color3.new(1, 1, 1)
  68. label.BorderColor3 = Color3.new(0, 0, 0)
  69. label.Parent = frame
  70. local label = Instance.new("TextLabel")
  71. label.Name = "Ammo"
  72. label.Text = "0/0"
  73. label.TextXAlignment = "Right"
  74. label.Size = UDim2.new(1, 0, 0, 20)
  75. label.Position = UDim2.new(0, -10, 0, 40)
  76. label.BackgroundTransparency = 1
  77. label.BorderSizePixel = 0
  78. label.Parent = frame
  79.  
  80.  
  81. function updateGui()
  82. if selected == false then return end
  83. if Player:FindFirstChild("PlayerGui") == nil then Instance.new("PlayerGui").Parent = Player end
  84. if Player.PlayerGui:FindFirstChild(Name) == nil then
  85. ammoGui:Clone().Parent = Player.PlayerGui
  86. end
  87. Player.PlayerGui[Name].Frame.Magazine.Text = tostring(magazine.Value).. "/" ..tostring(magazineMax.Value)
  88. Player.PlayerGui[Name].Frame.Ammo.Text = tostring(ammo.Value).. "/" ..tostring(ammoMax.Value)
  89. end
  90.  
  91.  
  92. function makeParts(format)
  93. local model = Instance.new("Model")
  94. model.Name = Name
  95. local pm = Instance.new("Part")
  96. pm.Name = "Handle"
  97. pm.FormFactor = "Custom"
  98. pm.Size = Vector3.new(1, 1, 1)
  99. pm.BrickColor = BrickColor.new("Black")
  100. pm.Locked = true
  101. pm.TopSurface = 0
  102. pm.BottomSurface = 0
  103. pm.Parent = model
  104. local m = Instance.new("CylinderMesh")
  105. m.Scale = Vector3.new(0.35, 1.5, 0.35)
  106. m.Parent = pm
  107. if format ~= nil then
  108. local w = Instance.new("Weld")
  109. w.Part0 = pm
  110. if format == "RightHand" then
  111. w.Part1 = Player.Character:FindFirstChild("Right Arm")
  112. w.C0 = CFrame.new(0, 1.5, 0.75)
  113. w.C1 = CFrame.new()
  114. elseif format == "RightHolster" then
  115. w.Part1 = Player.Character:FindFirstChild("Torso")
  116. w.C0 = CFrame.new(-0.65, 1, 0) * CFrame.fromEulerAnglesXYZ(math.rad(185), math.rad(90), 0)
  117. w.C1 = CFrame.new()
  118. model.Name = Name.. " (Holstered)"
  119. end
  120. w.Parent = pm
  121. model.Parent = Player.Character
  122. end
  123. --[[
  124. sniper1 http://www.roblox.com/Asset/?id=1868836
  125. equip http://www.roblox.com/Asset/?id=13510737
  126. fire1 http://www.roblox.com/Asset/?id=2760979
  127. fire2 http://www.roblox.com/Asset/?id=13510352
  128. fire3 http://www.roblox.com/Asset/?id=2692806
  129. fire4 http://www.roblox.com/Asset/?id=2691586
  130. fire5 http://www.roblox.com/Asset/?id=2920959
  131. fire6 http://www.roblox.com/Asset/?id=2697431
  132. fire7 http://www.roblox.com/Asset/?id=2920959
  133. reload1 http://www.roblox.com/Asset/?id=2691591
  134. reload2 http://www.roblox.com/Asset/?id=2697432
  135. reload3 http://www.roblox.com/Asset/?id=2920960
  136. reload4 http://www.roblox.com/Asset/?id=2761842
  137. shotgun1 http://www.roblox.com/Asset/?id=2697294
  138. --]]
  139. local s = Instance.new("Sound")
  140. s.Name = "Equip"
  141. s.SoundId = "http://www.roblox.com/Asset/?id=10209881"
  142. s.Volume = 1
  143. s.Pitch = 1
  144. s.Looped = false
  145. s.Parent = pm
  146. local s = Instance.new("Sound")
  147. s.Name = "Fire"
  148. s.SoundId = "rbxasset://sounds/Shoulder fired rocket.wav"
  149. s.Volume = 1
  150. s.Pitch = 1.25
  151. s.Looped = false
  152. s.Parent = pm
  153. local s = Instance.new("Sound")
  154. s.Name = "Reload"
  155. s.SoundId = "http://www.roblox.com/Asset/?id=2691591"
  156. s.Volume = 1
  157. s.Pitch = 1.25
  158. s.Looped = false
  159. s.Parent = pm
  160. local s = Instance.new("Sound")
  161. s.Name = "Empty"
  162. s.SoundId = "http://www.roblox.com/Asset/?id=2697295"
  163. s.Volume = 1
  164. s.Pitch = 5
  165. s.Looped = false
  166. s.Parent = pm
  167. local s = Instance.new("Sound")
  168. s.Name = "Switch"
  169. s.SoundId = "http://www.roblox.com/Asset/?id=2697295"
  170. s.Volume = 1
  171. s.Pitch = 10
  172. s.Looped = false
  173. s.Parent = pm
  174. local p = Instance.new("Part")
  175. p.Name = "Grip / Trigger Housing"
  176. p.FormFactor = "Custom"
  177. p.Size = Vector3.new(1, 1, 1)
  178. p.BrickColor = BrickColor.new("Black")
  179. p.Locked = true
  180. p.TopSurface = 0
  181. p.BottomSurface = 0
  182. p.Parent = model
  183. local m = Instance.new("SpecialMesh")
  184. m.MeshType = "Brick"
  185. m.Scale = Vector3.new(0.29, 0.75, 0.1)
  186. m.Parent = p
  187. local w = Instance.new("Weld")
  188. w.Part0 = p
  189. w.Part1 = pm
  190. w.C0 = CFrame.new(0, -0.2, -0.15)
  191. w.C1 = CFrame.new()
  192. w.Parent = p
  193. local p = Instance.new("Part")
  194. p.Name = "Grip 1"
  195. p.FormFactor = "Custom"
  196. p.Size = Vector3.new(1, 1, 1)
  197. p.BrickColor = BrickColor.new("Black")
  198. p.Locked = true
  199. p.TopSurface = 0
  200. p.BottomSurface = 0
  201. p.Parent = model
  202. local m = Instance.new("SpecialMesh")
  203. m.MeshType = "Brick"
  204. m.Scale = Vector3.new(0.29, 0.35, 0.9)
  205. m.Parent = p
  206. local w = Instance.new("Weld")
  207. w.Part0 = p
  208. w.Part1 = pm
  209. w.C0 = CFrame.new(0, -0.4, -0.65)
  210. w.C1 = CFrame.new()
  211. w.Parent = p
  212. local p = Instance.new("Part")
  213. p.Name = "Grip 2"
  214. p.FormFactor = "Custom"
  215. p.Size = Vector3.new(1, 1, 1)
  216. p.BrickColor = BrickColor.new("Reddish brown")
  217. p.Material = "Wood"
  218. p.Locked = true
  219. p.TopSurface = 0
  220. p.BottomSurface = 0
  221. p.Parent = model
  222. local m = Instance.new("SpecialMesh")
  223. m.MeshType = "Brick"
  224. m.Scale = Vector3.new(0.29, 0.35, 0.8)
  225. m.Parent = p
  226. local w = Instance.new("Weld")
  227. w.Part0 = p
  228. w.Part1 = pm
  229. w.C0 = CFrame.new(0, -1.1, -0.575)
  230. w.C1 = CFrame.new()
  231. w.Parent = p
  232. local p = Instance.new("Part")
  233. p.Name = "Trigger Housing 1"
  234. p.FormFactor = "Custom"
  235. p.Size = Vector3.new(1, 1, 1)
  236. p.BrickColor = BrickColor.new("Black")
  237. p.Locked = true
  238. p.TopSurface = 0
  239. p.BottomSurface = 0
  240. p.Parent = model
  241. local m = Instance.new("SpecialMesh")
  242. m.MeshType = "Brick"
  243. m.Scale = Vector3.new(0.1, 0.25, 0.025)
  244. m.Parent = p
  245. local w = Instance.new("Weld")
  246. w.Part0 = p
  247. w.Part1 = pm
  248. w.C0 = CFrame.new(0, -0.1, -0.5)
  249. w.C1 = CFrame.new()
  250. w.Parent = p
  251. local p = Instance.new("Part")
  252. p.Name = "Trigger Housing 2"
  253. p.FormFactor = "Custom"
  254. p.Size = Vector3.new(1, 1, 1)
  255. p.BrickColor = BrickColor.new("Black")
  256. p.Locked = true
  257. p.TopSurface = 0
  258. p.BottomSurface = 0
  259. p.Parent = model
  260. local m = Instance.new("SpecialMesh")
  261. m.MeshType = "Brick"
  262. m.Scale = Vector3.new(0.1, 0.025, 0.3)
  263. m.Parent = p
  264. local w = Instance.new("Weld")
  265. w.Part0 = p
  266. w.Part1 = pm
  267. w.C0 = CFrame.new(0, 0.01, -0.35)
  268. w.C1 = CFrame.new()
  269. w.Parent = p
  270. local p = Instance.new("Part")
  271. p.Name = "Trigger"
  272. p.FormFactor = "Custom"
  273. p.Size = Vector3.new(1, 1, 1)
  274. p.BrickColor = BrickColor.new("Black")
  275. p.Locked = true
  276. p.TopSurface = 0
  277. p.BottomSurface = 0
  278. p.Parent = model
  279. local m = Instance.new("SpecialMesh")
  280. m.MeshType = "Brick"
  281. m.Scale = Vector3.new(0.1, 0.05, 0.15)
  282. m.Parent = p
  283. local w = Instance.new("Weld")
  284. w.Part0 = p
  285. w.Part1 = pm
  286. w.C0 = CFrame.new(0, -0.11, -0.275)
  287. w.C1 = CFrame.new()
  288. w.Parent = p
  289. local p = Instance.new("Part")
  290. p.Name = "Center 1"
  291. p.FormFactor = "Custom"
  292. p.Size = Vector3.new(1, 1, 1)
  293. p.BrickColor = BrickColor.new("Black")
  294. p.Locked = true
  295. p.TopSurface = 0
  296. p.BottomSurface = 0
  297. p.Parent = model
  298. local m = Instance.new("CylinderMesh")
  299. m.Scale = Vector3.new(0.4, 0.5, 0.4)
  300. m.Parent = p
  301. local w = Instance.new("Weld")
  302. w.Part0 = p
  303. w.Part1 = pm
  304. w.C0 = CFrame.new(0, -1, 0)
  305. w.C1 = CFrame.new()
  306. w.Parent = p
  307. local p = Instance.new("Part")
  308. p.Name = "Center 2"
  309. p.FormFactor = "Custom"
  310. p.Size = Vector3.new(1, 1, 1)
  311. p.BrickColor = BrickColor.new("Reddish brown")
  312. p.Material = "Wood"
  313. p.Locked = true
  314. p.TopSurface = 0
  315. p.BottomSurface = 0
  316. p.Parent = model
  317. local m = Instance.new("CylinderMesh")
  318. m.Scale = Vector3.new(0.45, 1, 0.45)
  319. m.Parent = p
  320. local w = Instance.new("Weld")
  321. w.Part0 = p
  322. w.Part1 = pm
  323. w.C0 = CFrame.new(0, -1.75, 0)
  324. w.C1 = CFrame.new()
  325. w.Parent = p
  326. local p = Instance.new("Part")
  327. p.Name = "Center 3"
  328. p.FormFactor = "Custom"
  329. p.Size = Vector3.new(1, 1, 1)
  330. p.BrickColor = BrickColor.new("Reddish brown")
  331. p.Material = "Wood"
  332. p.Locked = true
  333. p.TopSurface = 0
  334. p.BottomSurface = 0
  335. p.Parent = model
  336. local m = Instance.new("SpecialMesh")
  337. m.MeshType = "FileMesh"
  338. m.MeshId = "http://www.roblox.com/Asset/?id=1778999"
  339. m.Scale = Vector3.new(0.335, 0.45, 0.335)
  340. m.Parent = p
  341. local w = Instance.new("Weld")
  342. w.Part0 = p
  343. w.Part1 = pm
  344. w.C0 = CFrame.new(0, -2.6225, 0)
  345. w.C1 = CFrame.new()
  346. w.Parent = p
  347. local p = Instance.new("Part")
  348. p.Name = "Center 4"
  349. p.FormFactor = "Custom"
  350. p.Size = Vector3.new(1, 1, 1)
  351. p.BrickColor = BrickColor.new("Reddish brown")
  352. p.Material = "Wood"
  353. p.Locked = true
  354. p.TopSurface = 0
  355. p.BottomSurface = 0
  356. p.Parent = model
  357. local m = Instance.new("CylinderMesh")
  358. m.Scale = Vector3.new(0.325, 1.25, 0.325)
  359. m.Parent = p
  360. local w = Instance.new("Weld")
  361. w.Part0 = p
  362. w.Part1 = pm
  363. w.C0 = CFrame.new(0, -3, 0)
  364. w.C1 = CFrame.new()
  365. w.Parent = p
  366. local p = Instance.new("Part")
  367. p.Name = "End 1"
  368. p.FormFactor = "Custom"
  369. p.Size = Vector3.new(1, 1, 1)
  370. p.BrickColor = BrickColor.new("Black")
  371. p.CanCollide = false
  372. p.Locked = true
  373. p.TopSurface = 0
  374. p.BottomSurface = 0
  375. p.Parent = model
  376. local m = Instance.new("CylinderMesh")
  377. m.Scale = Vector3.new(0.31, 0.1, 0.31)
  378. m.Parent = p
  379. local w = Instance.new("Weld")
  380. w.Part0 = p
  381. w.Part1 = pm
  382. w.C0 = CFrame.new(0, -3.625, 0)
  383. w.C1 = CFrame.new()
  384. w.Parent = p
  385. local p = Instance.new("Part")
  386. p.Name = "End 2"
  387. p.FormFactor = "Custom"
  388. p.Size = Vector3.new(1, 1, 1)
  389. p.BrickColor = BrickColor.new("Black")
  390. p.CanCollide = false
  391. p.Locked = true
  392. p.TopSurface = 0
  393. p.BottomSurface = 0
  394. p.Parent = model
  395. local m = Instance.new("SpecialMesh")
  396. m.MeshType = "FileMesh"
  397. m.MeshId = "http://www.roblox.com/Asset/?id=1778999"
  398. m.Scale = Vector3.new(0.425, 0.875, 0.425)
  399. m.Parent = p
  400. local w = Instance.new("Weld")
  401. w.Part0 = p
  402. w.Part1 = pm
  403. w.C0 = CFrame.new(0, 3.61, 0) * CFrame.fromEulerAnglesXYZ(math.rad(180), 0, 0)
  404. w.C1 = CFrame.new()
  405. w.Parent = p
  406. local f = Instance.new("Fire")
  407. f.Enabled = false
  408. f.Name = "Fire"
  409. f.Color = Color3.new(1, 0.5, 0)
  410. f.SecondaryColor = Color3.new(1, 0.75, 0.5)
  411. f.Heat = -25
  412. f.Size = 5
  413. f.Parent = p
  414. local s = Instance.new("Smoke")
  415. s.Enabled = false
  416. s.Name = "Smoke"
  417. s.Opacity = 0.5
  418. s.Color = Color3.new(0.8, 0.8, 0.8)
  419. s.RiseVelocity = -10
  420. s.Size = 5
  421. s.Parent = p
  422. local p = Instance.new("Part")
  423. p.Name = "Muzzle"
  424. p.FormFactor = "Custom"
  425. p.Size = Vector3.new(1, 1, 1)
  426. p.Transparency = 1
  427. p.CanCollide = false
  428. p.Locked = true
  429. p.Parent = model
  430. local w = Instance.new("Weld")
  431. w.Part0 = p
  432. w.Part1 = pm
  433. w.C0 = CFrame.new(0, 0.26, 0)
  434. w.C1 = CFrame.new()
  435. w.Parent = p
  436. local f = Instance.new("Fire")
  437. f.Enabled = false
  438. f.Name = "Fire"
  439. f.Color = Color3.new(1, 0.5, 0)
  440. f.SecondaryColor = Color3.new(1, 0.75, 0.5)
  441. f.Heat = -25
  442. f.Size = 2.5
  443. f.Parent = p
  444. local s = Instance.new("Smoke")
  445. s.Enabled = false
  446. s.Name = "Smoke"
  447. s.Opacity = 0.3
  448. s.Color = Color3.new(0.8, 0.8, 0.8)
  449. s.RiseVelocity = -10
  450. s.Size = 2.5
  451. s.Parent = p
  452. local pm2 = Instance.new("Part")
  453. if magazine.Value <= 0 then pm2.Transparency = 1 end
  454. pm2.Name = "Projectile"
  455. pm2.FormFactor = "Custom"
  456. pm2.Size = Vector3.new(1, 1, 1)
  457. pm2.BrickColor = BrickColor.new("Grime")
  458. pm2.CanCollide = false
  459. pm2.Locked = true
  460. pm2.TopSurface = 0
  461. pm2.BottomSurface = 0
  462. pm2.Parent = model
  463. local m = Instance.new("CylinderMesh")
  464. m.Scale = Vector3.new(0.2, 1, 0.2)
  465. m.Parent = pm2
  466. local w = Instance.new("Weld")
  467. w.Part0 = pm2
  468. w.Part1 = pm
  469. w.C0 = CFrame.new(0, 0.3, 0)
  470. w.C1 = CFrame.new()
  471. w.Parent = pm2
  472. local f = Instance.new("Fire")
  473. f.Enabled = false
  474. f.Name = "Fire"
  475. f.Color = Color3.new(1, 0.5, 0)
  476. f.SecondaryColor = Color3.new(1, 0.75, 0.5)
  477. f.Heat = 25
  478. f.Size = 1
  479. f.Parent = pm2
  480. local s = Instance.new("Smoke")
  481. s.Enabled = false
  482. s.Name = "Smoke"
  483. s.Opacity = 0.25
  484. s.Color = Color3.new(0.8, 0.8, 0.8)
  485. s.RiseVelocity = 10
  486. s.Size = 5
  487. s.Parent = pm2
  488. local p = Instance.new("Part")
  489. if magazine.Value <= 0 then p.Transparency = 1 end
  490. p.Name = "Projectile Center 1"
  491. p.FormFactor = "Custom"
  492. p.Size = Vector3.new(1, 1, 1)
  493. p.BrickColor = BrickColor.new("Grime")
  494. p.CanCollide = false
  495. p.Locked = true
  496. p.TopSurface = 0
  497. p.BottomSurface = 0
  498. p.Parent = model
  499. local m = Instance.new("SpecialMesh")
  500. m.MeshType = "FileMesh"
  501. m.MeshId = "http://www.roblox.com/Asset/?id=1033714" --http://www.roblox.com/Asset/?id=1778999
  502. m.Scale = Vector3.new(0.25, 1.25, 0.25)
  503. m.Parent = p
  504. local w = Instance.new("Weld")
  505. w.Part0 = p
  506. w.Part1 = pm2
  507. w.C0 = CFrame.new(0, 0.65, 0)
  508. w.C1 = CFrame.new()
  509. w.Parent = p
  510. local p = Instance.new("Part")
  511. if magazine.Value <= 0 then p.Transparency = 1 end
  512. p.Name = "Projectile Center 2"
  513. p.FormFactor = "Custom"
  514. p.Size = Vector3.new(1, 1, 1)
  515. p.BrickColor = BrickColor.new("Grime")
  516. p.CanCollide = false
  517. p.Locked = true
  518. p.TopSurface = 0
  519. p.BottomSurface = 0
  520. p.Parent = model
  521. local m = Instance.new("SpecialMesh")
  522. m.MeshType = "FileMesh"
  523. m.MeshId = "http://www.roblox.com/Asset/?id=1033714" --http://www.roblox.com/Asset/?id=1778999
  524. m.Scale = Vector3.new(0.25, 1.1, 0.25)
  525. m.Parent = p
  526. local w = Instance.new("Weld")
  527. w.Part0 = p
  528. w.Part1 = pm2
  529. w.C0 = CFrame.new(0, -1.53, 0) * CFrame.fromEulerAnglesXYZ(math.rad(180), 0, 0)
  530. w.C1 = CFrame.new()
  531. w.Parent = p
  532. local p = Instance.new("Part")
  533. if magazine.Value <= 0 then p.Transparency = 1 end
  534. p.Name = "Projectile Tip"
  535. p.FormFactor = "Custom"
  536. p.Size = Vector3.new(1, 1, 1)
  537. p.BrickColor = BrickColor.new("Grime")
  538. p.CanCollide = false
  539. p.Locked = true
  540. p.TopSurface = 0
  541. p.BottomSurface = 0
  542. p.Parent = model
  543. local m = Instance.new("CylinderMesh")
  544. m.Scale = Vector3.new(0.1, 0.1, 0.1)
  545. m.Parent = p
  546. local w = Instance.new("Weld")
  547. w.Part0 = p
  548. w.Part1 = pm2
  549. w.C0 = CFrame.new(0, 1.89, 0)
  550. w.C1 = CFrame.new()
  551. w.Parent = p
  552. return model
  553. end
  554.  
  555.  
  556. function removeParts(format)
  557. if format == "RightHand" then
  558. pcall(function() Player.Character[Name]:Remove() end)
  559. elseif format == "LeftHand" then
  560. pcall(function() Player.Character[Name.. " (Left)"]:Remove() end)
  561. elseif format == "RightHolster" then
  562. pcall(function() Player.Character[Name.. " (Holstered)"]:Remove() end)
  563. elseif format == "LeftHolster" then
  564. pcall(function() Player.Character[Name.. " (Holstered, Left)"]:Remove() end)
  565. end
  566. end
  567.  
  568.  
  569. function SetAngle(Joint, Angle, Character)
  570. if Character == nil then return false end
  571. local Joints = {
  572. Character.Torso:FindFirstChild("Right Shoulder 2"),
  573. Character.Torso:FindFirstChild("Left Shoulder 2"),
  574. Character.Torso:FindFirstChild("Right Hip 2"),
  575. Character.Torso:FindFirstChild("Left Hip 2")
  576. }
  577. if Joints[Joint] == nil then return false end
  578. if Joint == 1 or Joint == 3 then
  579. Joints[Joint].DesiredAngle = Angle
  580. end
  581. if Joint == 2 or Joint == 4 then
  582. Joints[Joint].DesiredAngle = -Angle
  583. end
  584. end
  585.  
  586.  
  587. function ForceAngle(Joint, Angle, Character)
  588. if Character == nil then return false end
  589. local Joints = {
  590. Character.Torso:FindFirstChild("Right Shoulder 2"),
  591. Character.Torso:FindFirstChild("Left Shoulder 2"),
  592. Character.Torso:FindFirstChild("Right Hip 2"),
  593. Character.Torso:FindFirstChild("Left Hip 2")
  594. }
  595. if Joints[Joint] == nil then return false end
  596. if Joint == 1 or Joint == 3 then
  597. Joints[Joint].DesiredAngle = Angle
  598. Joints[Joint].CurrentAngle = Angle
  599. end
  600. if Joint == 2 or Joint == 4 then
  601. Joints[Joint].DesiredAngle = -Angle
  602. Joints[Joint].CurrentAngle = -Angle
  603. end
  604. end
  605.  
  606.  
  607. function SetSpeed(Joint, Speed, Character)
  608. if Character == nil then return false end
  609. local Joints = {
  610. Character.Torso:FindFirstChild("Right Shoulder 2"),
  611. Character.Torso:FindFirstChild("Left Shoulder 2"),
  612. Character.Torso:FindFirstChild("Right Hip 2"),
  613. Character.Torso:FindFirstChild("Left Hip 2")
  614. }
  615. if Joints[Joint] == nil then return false end
  616. Joints[Joint].MaxVelocity = Speed
  617. end
  618.  
  619.  
  620. function DisableLimb(Limb, Character)
  621. if Character == nil then return false end
  622. if Character:FindFirstChild("Torso") == nil then return false end
  623. local Joints = {
  624. Character.Torso:FindFirstChild("Right Shoulder"),
  625. Character.Torso:FindFirstChild("Left Shoulder"),
  626. Character.Torso:FindFirstChild("Right Hip"),
  627. Character.Torso:FindFirstChild("Left Hip")
  628. }
  629. local Limbs = {
  630. Character:FindFirstChild("Right Arm"),
  631. Character:FindFirstChild("Left Arm"),
  632. Character:FindFirstChild("Right Leg"),
  633. Character:FindFirstChild("Left Leg")
  634. }
  635. if Joints[Limb] == nil then return false end
  636. if Limbs[Limb] == nil then return false end
  637. local Joint = Instance.new("Motor")
  638. Joint.Parent = Character.Torso
  639. Joint.Part0 = Character.Torso
  640. Joint.Part1 = Limbs[Limb]
  641. if Limb == 1 then
  642. Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  643. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  644. Joint.Name = "Right Shoulder 2"
  645. elseif Limb == 2 then
  646. Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  647. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  648. Joint.Name = "Left Shoulder 2"
  649. elseif Limb == 3 then
  650. Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  651. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  652. Joint.Name = "Right Hip 2"
  653. elseif Limb == 4 then
  654. Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  655. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  656. Joint.Name = "Left Hip 2"
  657. end
  658. Joint.MaxVelocity = Joints[Limb].MaxVelocity
  659. Joint.CurrentAngle = Joints[Limb].CurrentAngle
  660. Joint.DesiredAngle = Joints[Limb].DesiredAngle
  661. Joints[Limb]:Remove()
  662. end
  663.  
  664.  
  665. function ResetLimbCFrame(Limb, Character)
  666. if Character == nil then return false end
  667. if Character.Parent == nil then return false end
  668. if Character:FindFirstChild("Torso") == nil then return false end
  669. local Joints = {
  670. Character.Torso:FindFirstChild("Right Shoulder 2"),
  671. Character.Torso:FindFirstChild("Left Shoulder 2"),
  672. Character.Torso:FindFirstChild("Right Hip 2"),
  673. Character.Torso:FindFirstChild("Left Hip 2")
  674. }
  675. local Limbs = {
  676. Character:FindFirstChild("Right Arm"),
  677. Character:FindFirstChild("Left Arm"),
  678. Character:FindFirstChild("Right Leg"),
  679. Character:FindFirstChild("Left Leg")
  680. }
  681. if Joints[Limb] == nil then return false end
  682. if Limbs[Limb] == nil then return false end
  683. if Limb == 1 then
  684. Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  685. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  686. elseif Limb == 2 then
  687. Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  688. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  689. elseif Limb == 3 then
  690. Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  691. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  692. elseif Limb == 4 then
  693. Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  694. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  695. end
  696. end
  697.  
  698.  
  699. function EnableLimb(Limb, Character)
  700. if Character == nil then return false end
  701. if Character:FindFirstChild("Torso") == nil then return false end
  702. local Joints = {
  703. Character.Torso:FindFirstChild("Right Shoulder 2"),
  704. Character.Torso:FindFirstChild("Left Shoulder 2"),
  705. Character.Torso:FindFirstChild("Right Hip 2"),
  706. Character.Torso:FindFirstChild("Left Hip 2")
  707. }
  708. local Limbs = {
  709. Character:FindFirstChild("Right Arm"),
  710. Character:FindFirstChild("Left Arm"),
  711. Character:FindFirstChild("Right Leg"),
  712. Character:FindFirstChild("Left Leg")
  713. }
  714. if Joints[Limb] == nil then return false end
  715. if Limbs[Limb] == nil then return false end
  716. if Limb == 1 then
  717. Joints[Limb].Name = "Right Shoulder"
  718. elseif Limb == 2 then
  719. Joints[Limb].Name = "Left Shoulder"
  720. elseif Limb == 3 then
  721. Joints[Limb].Name = "Right Hip"
  722. elseif Limb == 4 then
  723. Joints[Limb].Name = "Left Hip"
  724. end
  725. Animate = Character:FindFirstChild("Animate")
  726. if Animate == nil then return false end
  727. Animate = Animate:Clone()
  728. Character.Animate:Remove()
  729. Animate.Parent = Character
  730. end
  731.  
  732.  
  733. function playAnimation(format, mouse)
  734. if format == "equip" then
  735. coroutine.resume(coroutine.create(function()
  736. for i = 0, 1, 0.025 do
  737. if Player.Character:FindFirstChild("Torso") ~= nil then
  738. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  739. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90) * i, 0, math.rad(67.5) * i)
  740. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(0, 0.5 * (1 - i), 0) * CFrame.new(0, 1.85 * i, 0)
  741. else return false end
  742. else return false end
  743. wait()
  744. end
  745. end))
  746. for i = 0, 1, 0.05 do
  747. if Player.Character:FindFirstChild("Torso") ~= nil then
  748. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  749. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.5, 0.5, -0.25 * i) * CFrame.fromEulerAnglesXYZ(math.rad(-90) * i, 0, math.rad(-20) * i)
  750. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.5, 0)
  751. else return false end
  752. else return false end
  753. wait()
  754. end
  755. removeParts("RightHolster")
  756. makeParts("RightHand")
  757. for i = 0, 1, 0.05 do
  758. if Player.Character:FindFirstChild("Torso") ~= nil then
  759. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  760. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.5 * (1 - i), 0.5 * (1 - i), -0.25 * (1 - i)) * CFrame.fromEulerAnglesXYZ(math.rad(-90) * (1 - i), 0, math.rad(-20) * (1 - i)) * CFrame.new(1.25 * i, 0.5 * i, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90) * i, 0, 0)
  761. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.5 * (1 - i), 0) * CFrame.new(0, 0.75 * i, 0.1 * i)
  762. else return false end
  763. else return false end
  764. if Player.Character:FindFirstChild(Name) ~= nil then
  765. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  766. Player.Character[Name].Handle.Weld.C0 = CFrame.new(0, 1.5, 0.75)
  767. Player.Character[Name].Handle.Weld.C1 = CFrame.fromEulerAnglesXYZ(math.rad(-90) * (1 - i), 0, 0)
  768. else return false end
  769. else return false end
  770. wait()
  771. end
  772. makeParts("RightHolster")
  773. removeParts("RightHand")
  774. return playAnimation("hold")
  775. end
  776. if format == "unequip" then
  777. coroutine.resume(coroutine.create(function()
  778. for i = 1, 0, -0.025 do
  779. if Player.Character:FindFirstChild("Torso") ~= nil then
  780. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  781. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90) * i, 0, math.rad(67.5) * i)
  782. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(0, 0.5 * (1 - i), 0) * CFrame.new(0, 1.85 * i, 0)
  783. else return false end
  784. else return false end
  785. wait()
  786. end
  787. end))
  788. for i = 1, 0, -0.05 do
  789. if Player.Character:FindFirstChild("Torso") ~= nil then
  790. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  791. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.5 * (1 - i), 0.5 * (1 - i), -0.25 * (1 - i)) * CFrame.fromEulerAnglesXYZ(math.rad(-90) * (1 - i), 0, math.rad(-20) * (1 - i)) * CFrame.new(1.25 * i, 0.5 * i, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90) * i, 0, 0)
  792. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.5 * (1 - i), 0) * CFrame.new(0, 0.75 * i, 0.1 * i)
  793. else return false end
  794. else return false end
  795. if Player.Character:FindFirstChild(Name) ~= nil then
  796. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  797. Player.Character[Name].Handle.Weld.C0 = CFrame.new(0, 1.5, 0.75)
  798. Player.Character[Name].Handle.Weld.C1 = CFrame.fromEulerAnglesXYZ(math.rad(-90) * (1 - i), 0, 0)
  799. else return false end
  800. else return false end
  801. wait()
  802. end
  803. makeParts("RightHolster")
  804. removeParts("RightHand")
  805. for i = 1, 0, -0.05 do
  806. if Player.Character:FindFirstChild("Torso") ~= nil then
  807. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  808. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.5, 0.5, -0.25 * i) * CFrame.fromEulerAnglesXYZ(math.rad(-90) * i, 0, math.rad(-20) * i)
  809. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.5, 0)
  810. else return false end
  811. else return false end
  812. wait()
  813. end
  814. removeParts("RightHolster")
  815. makeParts("RightHand")
  816. return true
  817. end
  818. if format == "hold" then
  819. if Player.Character:FindFirstChild("Torso") ~= nil then
  820. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  821. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(67.5))
  822. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(0, 1.85, 0)
  823. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.25, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0)
  824. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.75, 0.1)
  825. else return false end
  826. else return false end
  827. end
  828. if format == "reload" then
  829. Player.Character[Name].Handle.Reload.Volume = 0
  830. Player.Character[Name].Handle.Reload.Pitch = 1.78
  831. Player.Character[Name].Handle.Reload:Play()
  832. coroutine.resume(coroutine.create(function()
  833. for i = 0, 1, 0.06 do
  834. if Player.Character:FindFirstChild("Torso") ~= nil and Player.Character:FindFirstChild(Name) ~= nil then
  835. if Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil and Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  836. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.25 + i / 10, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(i * 90))
  837. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.75, 0.1)
  838. Player.Character[Name].Handle.Weld.C1 = CFrame.new(0, -1.4 * i, 0) * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-i * 170))
  839. end
  840. end
  841. wait()
  842. end
  843. end))
  844. for i = 1, 0, -0.1 do
  845. if Player.Character:FindFirstChild("Torso") ~= nil then
  846. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  847. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90) * i, 0, math.rad(67.5) * i)
  848. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(0, 0.5 * (1 - i), 0) * CFrame.new(0, 1.85 * i, 0)
  849. else return false end
  850. else return false end
  851. wait()
  852. end
  853. local projectile = Instance.new("Model")
  854. projectile.Name = Name.. " Projectile"
  855. local source = Player.Character[Name]:FindFirstChild("Projectile")
  856. if source == nil then return end
  857. source = source:Clone()
  858. source.Transparency = 0
  859. source.Parent = projectile
  860. for _, Part in pairs(Player.Character[Name]:GetChildren()) do
  861. if string.match(Part.Name, "Projectile") and Part.Name ~= "Projectile" then
  862. local new = Part:Clone()
  863. new.Parent = projectile
  864. new.Transparency = 0
  865. --new.CFrame = source.CFrame * (Part.Weld.C0 * Part.Weld.C1):inverse()
  866. local w = Instance.new("Weld", new)
  867. w.Part0 = w.Parent
  868. w.Part1 = source
  869. w.C0 = Part.Weld.C0
  870. w.C1 = Part.Weld.C1
  871. end
  872. end
  873. local w = Instance.new("Weld", source)
  874. w.Part0 = w.Parent
  875. w.Part1 = Player.Character:FindFirstChild("Left Arm")
  876. w.C0 = CFrame.new(0.2, -0.8, -0.6) * CFrame.fromEulerAnglesXYZ(math.rad(180), 0, math.rad(-37.5))
  877. projectile.Parent = Player.Character[Name]
  878. for i = 0, 1, 0.1 do
  879. if Player.Character:FindFirstChild("Torso") ~= nil then
  880. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  881. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(110) * i, 0, math.rad(67.5) * i)
  882. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(0, 0.5 * (1 - i), 0) * CFrame.new(0.35 * i, 1.85 * i, 0)
  883. else return false end
  884. else return false end
  885. wait()
  886. end
  887. Player.Character[Name].Handle.Reload.Volume = 1
  888. Player.Character[Name].Handle.Reload.Pitch = 0.9
  889. for i = 0, 0.9, 0.1 do
  890. if Player.Character:FindFirstChild("Torso") ~= nil then
  891. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  892. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new(-1.5 + i, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(110), 0, math.rad(67.5))
  893. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(0.35 * (1 - i), 1.85, 0)
  894. else return false end
  895. else return false end
  896. wait()
  897. end
  898. projectile:Remove()
  899. Player.Character[Name].Handle.Reload:Stop()
  900. for _, Part in pairs(Player.Character[Name]:GetChildren()) do
  901. if string.match(Part.Name, "Projectile") then
  902. Part.Transparency = 0
  903. end
  904. end
  905. coroutine.resume(coroutine.create(function()
  906. for i = 1, 0, -0.1 do
  907. if Player.Character:FindFirstChild("Torso") ~= nil and Player.Character:FindFirstChild(Name) ~= nil then
  908. if Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil and Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  909. Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.25 + i / 10, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(i * 90))
  910. Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.75, 0.1)
  911. Player.Character[Name].Handle.Weld.C1 = CFrame.new(0, -1.4 * i, 0) * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-i * 170))
  912. end
  913. end
  914. wait()
  915. end
  916. end))
  917. for i = 0.9, 0, -0.1 do
  918. if Player.Character:FindFirstChild("Torso") ~= nil then
  919. if Player.Character.Torso:FindFirstChild("Left Shoulder 2") ~= nil and Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
  920. Player.Character.Torso["Left Shoulder 2"].C0 = CFrame.new(-1.5 + i, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(110), 0, math.rad(67.5))
  921. Player.Character.Torso["Left Shoulder 2"].C1 = CFrame.new(0, 1.85, 0)
  922. else return false end
  923. else return false end
  924. wait()
  925. end
  926. Player.Character[Name].Handle.Weld.C1 = CFrame.new()
  927. playAnimation("hold")
  928. return true
  929. end
  930. if format == "fire" then
  931. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  932. Player.Character[Name].Handle.Fire:Play()
  933. CamShake(0.1, 5000)
  934. else return false end
  935. if Player.Character:FindFirstChild("Humanoid") ~= nil then
  936. coroutine.resume(coroutine.create(function() if Player.Character.Humanoid.PlatformStand == false and Player.Character.Humanoid.Sit == false then Player.Character.Humanoid.PlatformStand = true wait(0.1) Player.Character.Humanoid.PlatformStand = false end end))
  937. else return false end
  938. if Player.Character:FindFirstChild("Torso") ~= nil then
  939. coroutine.resume(coroutine.create(function() Player.Character.Torso.Velocity = Player.Character.Torso.Velocity + (Player.Character.Torso.CFrame.lookVector * -100) + Vector3.new(0, 25, 0) end))
  940. else return false end
  941. if Player.Character[Name]:FindFirstChild("Muzzle") ~= nil then
  942. coroutine.resume(coroutine.create(function() Player.Character[Name].Muzzle.Smoke.Enabled = true Player.Character[Name].Muzzle.Fire.Enabled = true wait(0.5) Player.Character[Name].Muzzle.Smoke.Enabled = false Player.Character[Name].Muzzle.Fire.Enabled = false end))
  943. else return false end
  944. if Player.Character[Name]:FindFirstChild("End 2") ~= nil then
  945. coroutine.resume(coroutine.create(function() Player.Character[Name]["End 2"].Smoke.Enabled = true Player.Character[Name]["End 2"].Fire.Enabled = true wait(0.5) Player.Character[Name]["End 2"].Smoke.Enabled = false Player.Character[Name]["End 2"].Fire.Enabled = false end))
  946. else return false end
  947. end
  948. return true
  949. end
  950.  
  951.  
  952. function CamShake(time, freq)
  953. coroutine.resume(coroutine.create(function()
  954. local cam = Workspace.CurrentCamera
  955. local time = 10
  956. local seed = Vector3.new(math.random(100, 200) / freq, math.random(100, 200) / freq, 0)
  957. if math.random(1, 2) == 1 then seed = Vector3.new(-seed.x, seed.y, 0) end
  958. if math.random(1, 2) == 1 then seed = Vector3.new(seed.x, -seed.y, 0) end
  959. cam.CoordinateFrame = (CFrame.new(cam.Focus.p) * (cam.CoordinateFrame - cam.CoordinateFrame.p) * CFrame.fromEulerAnglesXYZ(seed.x * time, seed.y * time, 0)) * CFrame.new(0, 0, (cam.CoordinateFrame.p - cam.Focus.p).magnitude)
  960. for i = 1, time do
  961. cam.CoordinateFrame = (CFrame.new(cam.Focus.p) * (cam.CoordinateFrame - cam.CoordinateFrame.p) * CFrame.fromEulerAnglesXYZ(-seed.x, -seed.y, 0)) * CFrame.new(0, 0, (cam.CoordinateFrame.p - cam.Focus.p).magnitude)
  962. wait()
  963. end
  964. end))
  965. end
  966.  
  967.  
  968. function Weld(x, y)
  969. local weld = Instance.new("Weld")
  970. weld.Part0 = x
  971. weld.Part1 = y
  972. CJ = CFrame.new(x.Position)
  973. C0 = x.CFrame:inverse() * CJ
  974. C1 = y.CFrame:inverse() * CJ
  975. weld.C0 = C0
  976. weld.C1 = C1
  977. weld.Parent = x
  978. end
  979.  
  980.  
  981. function tagHumanoid(humanoid)
  982. local tag = Instance.new("ObjectValue")
  983. tag.Name = "creator"
  984. tag.Value = Player
  985. tag.Parent = humanoid
  986. local tag = Instance.new("StringValue")
  987. tag.Name = "creatorType1"
  988. tag.Value = Name
  989. tag.Parent = humanoid
  990. local tag = Instance.new("StringValue")
  991. tag.Name = "creatorType2"
  992. tag.Value = "blown to bits"
  993. tag.Parent = humanoid
  994. end
  995.  
  996.  
  997. function untagHumanoid(humanoid)
  998. if humanoid ~= nil then
  999. local tag = humanoid:FindFirstChild("creator")
  1000. if tag ~= nil then
  1001. tag:Remove()
  1002. end
  1003. local tag = humanoid:FindFirstChild("creatorType1")
  1004. if tag ~= nil then
  1005. tag:Remove()
  1006. end
  1007. local tag = humanoid:FindFirstChild("creatorType2")
  1008. if tag ~= nil then
  1009. tag:Remove()
  1010. end
  1011. end
  1012. end
  1013.  
  1014.  
  1015. function fire(startPoint, endPoint, hit)
  1016. local projectile = Instance.new("Model")
  1017. projectile.Name = Name.. " Projectile"
  1018. local source = Player.Character[Name]:FindFirstChild("Projectile")
  1019. if source == nil then return end
  1020. source.Transparency = 1
  1021. source = source:Clone()
  1022. source.Transparency = 0
  1023. source.CanCollide = false
  1024. pcall(function() source.Fire.Enabled = true end)
  1025. pcall(function() source.Smoke.Enabled = true end)
  1026. source.CFrame = CFrame.new(startPoint, endPoint) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0)
  1027. source.Parent = projectile
  1028. for _, Part in pairs(Player.Character[Name]:GetChildren()) do
  1029. if string.match(Part.Name, "Projectile") and Part.Name ~= "Projectile" then
  1030. local new = Part:Clone()
  1031. new.Parent = projectile
  1032. new.Transparency = 0
  1033. new.CFrame = source.CFrame * (Part.Weld.C0 * Part.Weld.C1):inverse()
  1034. local w = Instance.new("Weld", new)
  1035. w.Part0 = w.Parent
  1036. w.Part1 = source
  1037. w.C0 = Part.Weld.C0
  1038. w.C1 = Part.Weld.C1
  1039. Part.Transparency = 1
  1040. end
  1041. end
  1042. projectile.Parent = Workspace
  1043. local vel = Instance.new("BodyVelocity")
  1044. vel.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  1045. vel.velocity = (endPoint - startPoint).unit * 100
  1046. vel.Parent = source
  1047. local gyro = Instance.new("BodyGyro")
  1048. gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  1049. gyro.cframe = CFrame.new(startPoint, endPoint) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0)
  1050. gyro.Parent = source
  1051. coroutine.resume(coroutine.create(function() wait(1) gyro:Remove() end))
  1052. wait(0.2)
  1053. source.CanCollide = true
  1054. local connection = nil
  1055. connection = source.Touched:connect(function()
  1056. if hit.Parent == nil then return end
  1057. if hit.Parent == projectile then return end
  1058. if hit.Parent == Player.Character then return end
  1059. if hit.Parent == Player.Character:FindFirstChild(Name) then return end
  1060. if hit.Parent.Parent == Player.Character then return end
  1061. for i = 1, math.random(3, 6) do
  1062. local s = Instance.new("Sound", source)
  1063. s.SoundId = "http://www.roblox.com/Asset/?id=2101148"
  1064. s.Volume = 1
  1065. s.Pitch = math.random(1, 10) / 10
  1066. s:Play()
  1067. end
  1068. coroutine.resume(coroutine.create(function()
  1069. pcall(function() vel:Remove() end)
  1070. for _, Part in pairs(projectile:GetChildren()) do
  1071. if Part.Name ~= "Projectile" then
  1072. Part:Remove()
  1073. else
  1074. Part.Anchored = true
  1075. Part.Transparency = 1
  1076. Part.CanCollide = false
  1077. pcall(function() Part.Fire.Enabled = false end)
  1078. pcall(function() Part.Smoke.Enabled = false end)
  1079. end
  1080. end
  1081. connection:disconnect()
  1082. wait(5)
  1083. projectile:Remove()
  1084. end))
  1085. local range = damage / 5
  1086. local power = damage / 2
  1087. local function Push(Part)
  1088. if #Part:GetChildren() > 0 then for _, Parts in pairs(Part:GetChildren()) do Push(Parts) end end
  1089. if pcall(function() local x = Part.CFrame end) == false then return end
  1090. if Part.Anchored == true then return end
  1091. if (Part.Position - source.Position).magnitude > range then return end
  1092. if Part.Parent:FindFirstChild("Humanoid") ~= nil then
  1093. tagHumanoid(Part.Parent.Humanoid)
  1094. if math.random(1, 3) == 1 then Part.Parent.Humanoid.Sit = true end
  1095. Part.Parent.Humanoid:TakeDamage(math.random(1, damage) / 6)
  1096. delay(0.1, function() untagHumanoid(Part.Parent.Humanoid) end)
  1097. end
  1098. if (Part.Position - source.Position).magnitude < range / 2 then if math.random(1, 5) == 1 then Part:BreakJoints() end else if math.random(1, 25) == 1 then Part:BreakJoints() end end
  1099. Part.Velocity = Part.Velocity + ((Part.Position - source.Position).unit * power)
  1100. end
  1101. Push(Workspace)
  1102. for i = 1, math.random(5, 20) do
  1103. local blast = Instance.new("Part")
  1104. blast.FormFactor = 0
  1105. blast.Size = Vector3.new(1, 1, 1)
  1106. local color = math.random(1, 6)
  1107. if color == 1 then
  1108. blast.BrickColor = BrickColor.new("Institutional white")
  1109. elseif color == 2 then
  1110. blast.BrickColor = BrickColor.new("White")
  1111. elseif color == 3 then
  1112. blast.BrickColor = BrickColor.new("Really red")
  1113. elseif color == 4 then
  1114. blast.BrickColor = BrickColor.new("Really black")
  1115. elseif color == 5 then
  1116. blast.BrickColor = BrickColor.new("Black")
  1117. elseif color == 6 then
  1118. blast.BrickColor = BrickColor.new("Bright red")
  1119. end
  1120. blast.TopSurface = 0
  1121. blast.BottomSurface = 0
  1122. blast.Anchored = true
  1123. blast.CanCollide = false
  1124. blast.CFrame = source.CFrame * CFrame.new(math.random(-damage / 50, damage / 50), math.random(-damage / 50, damage / 50), math.random(-damage / 50, damage / 50))
  1125. blast.Parent = Workspace
  1126. local mesh = Instance.new("SpecialMesh")
  1127. mesh.MeshType = "Sphere"
  1128. mesh.Parent = blast
  1129. coroutine.resume(coroutine.create(function()
  1130. for i = 1, range, math.random(range, range + 100) / 100 do
  1131. blast.Transparency = i / range
  1132. mesh.Scale = Vector3.new(i, i, i)
  1133. wait()
  1134. end
  1135. blast:Remove()
  1136. end))
  1137. end
  1138. end)
  1139. coroutine.resume(coroutine.create(function()
  1140. wait(10)
  1141. for _, Part in pairs(projectile:GetChildren()) do
  1142. Part.CanCollide = false
  1143. end
  1144. pcall(function() source.Fire.Enabled = false end)
  1145. pcall(function() source.Smoke.Enabled = false end)
  1146. pcall(function() vel:Remove() end)
  1147. pcall(function() connection:disconnect() end)
  1148. end))
  1149. end
  1150.  
  1151.  
  1152. function onButton1Down(mouse)
  1153. if selected == false then return end
  1154. if Player.Character:FindFirstChild(Name) ~= nil and Button1Down == false and canFire == true and (function() if dual == true then if Player.Character:FindFirstChild(Name.. " (Left)") ~= nil then return true else return false end else return true end end)() == true then
  1155. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  1156. if Player.Character[Name]:FindFirstChild("Muzzle") == nil then return end
  1157. if dual == true then if Player.Character[Name.. " (Left)"]:FindFirstChild("Handle") == nil then return end end
  1158. if dual == true then if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle") == nil then return end end
  1159. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1160. Button1Down = true
  1161. canFire = false
  1162. canFire2 = true
  1163. while canFire2 == true do
  1164. local humanoid = Player.Character:FindFirstChild("Humanoid")
  1165. if humanoid == nil then
  1166. canFire2 = false
  1167. break
  1168. end
  1169. if humanoid.Health <= 0 then
  1170. canFire2 = false
  1171. break
  1172. end
  1173. local fireLeft = false
  1174. if automatic == false and burst == false then
  1175. canFire2 = false
  1176. elseif automatic == false and burst == true then
  1177. if burstCount >= burstCountMax then
  1178. canFire2 = false
  1179. burstCount = 0
  1180. break
  1181. end
  1182. burstCount = burstCount + 1
  1183. elseif automatic == true and burst == false then
  1184. fireLeft = true
  1185. end
  1186. if magazine.Value > 0 then
  1187. magazine.Value = magazine.Value - 1
  1188. updateGui()
  1189. fire(Player.Character[Name].Muzzle.Position, mouse.Hit.p, mouse.Target)
  1190. coroutine.resume(coroutine.create(function()
  1191. if dual == true then
  1192. playAnimation("rightFire")
  1193. elseif dual == false then
  1194. playAnimation("fire")
  1195. end
  1196. end))
  1197. else
  1198. Player.Character[Name].Handle.Empty:Play()
  1199. end
  1200. if fireLeft == true and dual == true and automatic == true then
  1201. if magazine.Value > 0 then
  1202. coroutine.resume(coroutine.create(function()
  1203. wait(readyTime / 2)
  1204. magazine.Value = magazine.Value - 1
  1205. updateGui()
  1206. fire(Player.Character[Name.. " (Left)"].Muzzle.Position, mouse.Hit.p, mouse.Target)
  1207. playAnimation("leftFire")
  1208. end))
  1209. else
  1210. coroutine.resume(coroutine.create(function()
  1211. wait(readyTime / 2)
  1212. Player.Character[Name].Handle.Empty:Play()
  1213. end))
  1214. end
  1215. end
  1216. wait(readyTime)
  1217. end
  1218. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1219. canFire = true
  1220. end
  1221. end
  1222.  
  1223.  
  1224. function onButton1Up(mouse)
  1225. if selected == false then return end
  1226. Button1Down = false
  1227. canFire2 = false
  1228. burstCount = 0
  1229. while canFire == false do wait() end
  1230. if dual == true and automatic == false then
  1231. if Player.Character[Name.. " (Left)"]:FindFirstChild("Handle") == nil then return end
  1232. if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle") == nil then return end
  1233. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1234. canFire = false
  1235. canFire2 = true
  1236. while canFire2 == true do
  1237. local humanoid = Player.Character:FindFirstChild("Humanoid")
  1238. if humanoid == nil then
  1239. canFire2 = false
  1240. break
  1241. end
  1242. if humanoid.Health <= 0 then
  1243. canFire2 = false
  1244. break
  1245. end
  1246. if burst == false then
  1247. canFire2 = false
  1248. elseif burst == true then
  1249. if burstCount >= burstCountMax then
  1250. canFire2 = false
  1251. burstCount = 0
  1252. break
  1253. end
  1254. burstCount = burstCount + 1
  1255. end
  1256. if magazine.Value <= 0 then
  1257. Player.Character[Name].Handle.Empty:Play()
  1258. else
  1259. coroutine.resume(coroutine.create(function()
  1260. playAnimation("leftFire")
  1261. end))
  1262. magazine.Value = magazine.Value - 1
  1263. updateGui()
  1264. fire(Player.Character[Name.. " (Left)"].Muzzle.Position, mouse.Hit.p, mouse.Target)
  1265. end
  1266. wait(readyTime)
  1267. end
  1268. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1269. canFire = true
  1270. end
  1271. end
  1272.  
  1273.  
  1274. function onKeyDown(key, mouse)
  1275. if selected == false then return end
  1276. key = key:lower()
  1277. if key == "q" and Button1Down == false and canFire == true then
  1278. if mouse.Target == nil then return end
  1279. if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
  1280. if dual == true then onKeyDown("t", mouse) end
  1281. onDeselected(mouse)
  1282. removeParts("RightHolster")
  1283. script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
  1284. end
  1285. end
  1286. if key == "e" and Button1Down == false and canFire == true and canSilence == true then
  1287. if silenced then
  1288. silenced = false
  1289. if Player.Character:FindFirstChild(Name) == nil then return end
  1290. if Player.Character[Name]:FindFirstChild("Muzzle") == nil then return end
  1291. if Player.Character[Name]:FindFirstChild("Muzzle 2") == nil then return end
  1292. Player.Character[Name].Muzzle.Transparency = 1
  1293. Player.Character[Name].Muzzle.Name = "Silencer"
  1294. Player.Character[Name]["Muzzle 2"].Name = "Muzzle"
  1295. if dual == true then
  1296. if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle") == nil then return end
  1297. if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle 2") == nil then return end
  1298. Player.Character[Name.. " (Left)"].Muzzle.Transparency = 1
  1299. Player.Character[Name.. " (Left)"].Muzzle.Name = "Silencer"
  1300. Player.Character[Name.. " (Left)"]["Muzzle 2"].Name = "Muzzle"
  1301. end
  1302. else
  1303. silenced = true
  1304. if Player.Character:FindFirstChild(Name) == nil then return end
  1305. if Player.Character[Name]:FindFirstChild("Silencer") == nil then return end
  1306. if Player.Character[Name]:FindFirstChild("Muzzle") == nil then return end
  1307. Player.Character[Name].Silencer.Transparency = 0
  1308. Player.Character[Name].Muzzle.Name = "Muzzle 2"
  1309. Player.Character[Name].Silencer.Name = "Muzzle"
  1310. if dual == true then
  1311. if Player.Character[Name.. " (Left)"]:FindFirstChild("Silencer") == nil then return end
  1312. if Player.Character[Name.. " (Left)"]:FindFirstChild("Muzzle") == nil then return end
  1313. Player.Character[Name.. " (Left)"].Silencer.Transparency = 0
  1314. Player.Character[Name.. " (Left)"].Muzzle.Name = "Muzzle 2"
  1315. Player.Character[Name.. " (Left)"].Silencer.Name = "Muzzle"
  1316. end
  1317. end
  1318. end
  1319. if key == "r" and Button1Down == false and canFire == true then
  1320. if ammo.Value > 0 and magazine.Value ~= magazineMax.Value then
  1321. canFire = false
  1322. burstCount = 0
  1323. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1324. if magazine.Value > 0 then ammo.Value = ammo.Value + magazine.Value magazine.Value = 0 end
  1325. updateGui()
  1326. if dual == true then
  1327. playAnimation("reloadDual")
  1328. elseif dual == false then
  1329. playAnimation("reload")
  1330. end
  1331. if ammo.Value - magazineMax.Value < 0 then
  1332. magazine.Value = ammo.Value
  1333. ammo.Value = 0
  1334. elseif ammo.Value - magazineMax.Value >= 0 then
  1335. ammo.Value = ammo.Value - magazineMax.Value
  1336. magazine.Value = magazineMax.Value
  1337. end
  1338. updateGui()
  1339. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1340. canFire = true
  1341. end
  1342. end
  1343. if key == "t" and Button1Down == false and canFire == true and canDual == true then
  1344. canFire = false
  1345. if dual == false then
  1346. local weapon = nil
  1347. for _, p in pairs(Player.Backpack:GetChildren()) do
  1348. if p.Name == Name and p ~= script.Parent then weapon = p break end
  1349. end
  1350. if weapon ~= nil then
  1351. dual = true
  1352. weapon.Name = "Dual"
  1353. weapon.Parent = script
  1354. silenced = false
  1355. removeParts("RightHand")
  1356. makeParts("RightHand")
  1357. removeParts("RightHolster")
  1358. makeParts("LeftHolster")
  1359. playAnimation("leftEquip")
  1360. removeParts("LeftHolster")
  1361. makeParts("LeftHand")
  1362. magazineMax.Value = math.ceil(magazineMax.Value * 2)
  1363. ammoMax.Value = math.ceil(ammoMax.Value * 2)
  1364. magazine.Value = magazine.Value + weapon.Magazine.Value
  1365. ammo.Value = ammo.Value + weapon.Ammo.Value
  1366. updateGui()
  1367. end
  1368. elseif dual == true then
  1369. local weapon = script:FindFirstChild("Dual")
  1370. if weapon ~= nil then
  1371. dual = false
  1372. weapon.Name = Name
  1373. weapon.Parent = Player.Backpack
  1374. silenced = false
  1375. removeParts("RightHand")
  1376. makeParts("RightHand")
  1377. playAnimation("leftUnequip")
  1378. removeParts("LeftHand")
  1379. makeParts("RightHolster")
  1380. playAnimation("hold")
  1381. weapon.Magazine.Value = math.floor(magazine.Value / 2)
  1382. weapon.Ammo.Value = math.floor(ammo.Value / 2)
  1383. magazineMax.Value = math.ceil(magazineMax.Value / 2)
  1384. ammoMax.Value = math.ceil(ammoMax.Value / 2)
  1385. magazine.Value = math.ceil(magazine.Value / 2)
  1386. ammo.Value = math.ceil(ammo.Value / 2)
  1387. updateGui()
  1388. end
  1389. end
  1390. canFire = true
  1391. end
  1392. if key == "y" and canZoom == true then
  1393. if zoom == false then
  1394. zoom = true
  1395. local pos = mouse.Hit.p
  1396. local target = mouse.Target
  1397. local cam = Workspace.CurrentCamera
  1398. focus = Instance.new("Part", Workspace)
  1399. focus.Anchored = true
  1400. focus.CanCollide = false
  1401. focus.Transparency = 1
  1402. focus.TopSurface = 0
  1403. focus.BottomSurface = 0
  1404. focus.FormFactor = "Plate"
  1405. focus.Size = Vector3.new(0, 0, 0)
  1406. focus.CFrame = CFrame.new(pos) * (CFrame.new(Player.Character.Torso.Position, pos) - CFrame.new(Player.Character.Torso.Position, pos).p)
  1407. cam.CameraSubject = focus
  1408. cam.CameraType = "Attach"
  1409. while zoom == true and selected == true do
  1410. local set = false
  1411. if target ~= nil then
  1412. if target.Parent ~= nil then
  1413. if target.Anchored == false then
  1414. focus.CFrame = CFrame.new(target.Position) * (CFrame.new(Player.Character.Torso.Position, target.Position) - CFrame.new(Player.Character.Torso.Position, target.Position).p)
  1415. set = true
  1416. end
  1417. end
  1418. end
  1419. if set == false then
  1420. focus.CFrame = CFrame.new(pos) * (CFrame.new(Player.Character.Torso.Position, pos) - CFrame.new(Player.Character.Torso.Position, pos).p)
  1421. end
  1422. wait()
  1423. end
  1424. if focus ~= nil then focus:Remove() focus = nil end
  1425. local cam = Workspace.CurrentCamera
  1426. cam.CameraSubject = Player.Character:FindFirstChild("Humanoid")
  1427. cam.CameraType = "Custom"
  1428. else
  1429. zoom = false
  1430. end
  1431. end
  1432. if key == "u" and Button1Down == false and canFire == true then
  1433. if automatic == false and burst == false then
  1434. if switchToBurst == true then
  1435. burst = true
  1436. local m = Instance.new("Message", Player)
  1437. m.Text = "Burst"
  1438. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1439. delay(2.5, function() m:Remove() end)
  1440. elseif switchToAutomatic == true then
  1441. automatic = true
  1442. local m = Instance.new("Message", Player)
  1443. m.Text = "Automatic"
  1444. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1445. delay(2.5, function() m:Remove() end)
  1446. end
  1447. elseif automatic == false and burst == true then
  1448. if switchToAutomatic == true then
  1449. automatic = true
  1450. burst = false
  1451. local m = Instance.new("Message", Player)
  1452. m.Text = "Automatic"
  1453. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1454. delay(2.5, function() m:Remove() end)
  1455. elseif switchToSingle == true then
  1456. burst = false
  1457. local m = Instance.new("Message", Player)
  1458. m.Text = "Single"
  1459. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1460. delay(2.5, function() m:Remove() end)
  1461. end
  1462. elseif automatic == true and burst == false then
  1463. if switchToSingle == true then
  1464. automatic = false
  1465. local m = Instance.new("Message", Player)
  1466. m.Text = "Single"
  1467. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1468. delay(2.5, function() m:Remove() end)
  1469. elseif switchToBurst == true then
  1470. automatic = false
  1471. burst = true
  1472. local m = Instance.new("Message", Player)
  1473. m.Text = "Burst"
  1474. pcall(function() Player.Character[Name].Handle.Switch:Play() end)
  1475. delay(2.5, function() m:Remove() end)
  1476. end
  1477. end
  1478. end
  1479. end
  1480.  
  1481.  
  1482. function onSelected(mouse)
  1483. if selected == true then return end
  1484. selected = true
  1485. canFire = false
  1486. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1487. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  1488. if Player.Character.WeaponActivated.Value == nil then break end
  1489. if Player.Character.WeaponActivated.Value.Parent == nil then break end
  1490. wait()
  1491. end
  1492. updateGui()
  1493. local weapon = Instance.new("ObjectValue")
  1494. weapon.Name = "WeaponActivated"
  1495. weapon.Value = script.Parent
  1496. weapon.Parent = Player.Character
  1497. DisableLimb(1, Player.Character)
  1498. DisableLimb(2, Player.Character)
  1499. ForceAngle(1, 0, Player.Character)
  1500. ForceAngle(2, 0, Player.Character)
  1501. if dual == true then
  1502. coroutine.resume(coroutine.create(function() playAnimation("leftEquip") end))
  1503. playAnimation("rightEquip")
  1504. removeParts("LeftHolster")
  1505. makeParts("LeftHand")
  1506. else
  1507. playAnimation("equip")
  1508. end
  1509. removeParts("RightHolster")
  1510. makeParts("RightHand")
  1511. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  1512. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  1513. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  1514. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1515. canFire = true
  1516. end
  1517.  
  1518.  
  1519. function onDeselected(mouse)
  1520. if selected == false then return end
  1521. Button1Down = false
  1522. while canFire == false do
  1523. wait()
  1524. end
  1525. selected = false
  1526. if dual == true then
  1527. if math.random(1, 2) == 1 then
  1528. coroutine.resume(coroutine.create(function() playAnimation("leftUnequip") end))
  1529. wait(math.random(1, 10) / 10)
  1530. playAnimation("rightUnequip")
  1531. else
  1532. coroutine.resume(coroutine.create(function() playAnimation("rightUnequip") end))
  1533. wait(math.random(1, 10) / 10)
  1534. playAnimation("leftUnequip")
  1535. end
  1536. removeParts("LeftHand")
  1537. makeParts("LeftHolster")
  1538. else
  1539. playAnimation("unequip")
  1540. end
  1541. removeParts("RightHand")
  1542. makeParts("RightHolster")
  1543. ForceAngle(1, 0, Player.Character)
  1544. ForceAngle(2, 0, Player.Character)
  1545. ResetLimbCFrame(1, Player.Character)
  1546. ResetLimbCFrame(2, Player.Character)
  1547. EnableLimb(1, Player.Character)
  1548. EnableLimb(2, Player.Character)
  1549. silenced = false
  1550. if Player.PlayerGui:FindFirstChild(Name) ~= nil then Player.PlayerGui[Name]:Remove() end
  1551. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  1552. if Player.Character.WeaponActivated.Value == script.Parent then
  1553. Player.Character.WeaponActivated:Remove()
  1554. end
  1555. end
  1556. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  1557. if Player.Character.WeaponActivated.Value == nil then break end
  1558. if Player.Character.WeaponActivated.Value.Parent == nil then break end
  1559. wait()
  1560. end
  1561. end
  1562.  
  1563.  
  1564. if script.Parent.ClassName ~= "HopperBin" then
  1565. if Player == nil then print("Error: Player not found!") return end
  1566. Tool = Instance.new("HopperBin")
  1567. Tool.Name = Name
  1568. Tool.Parent = Player.Backpack
  1569. script.Name = "Main"
  1570. script.Parent = Tool
  1571. end
  1572. wait()
  1573. if script.Parent.ClassName == "HopperBin" then
  1574. while script.Parent.Parent.ClassName ~= "Backpack" do
  1575. wait()
  1576. end
  1577. if script.Parent:FindFirstChild("MagazineMax") == nil then
  1578. magazineMax = Instance.new("NumberValue")
  1579. magazineMax.Name = "MagazineMax"
  1580. magazineMax.Value = 1
  1581. magazineMax.Parent = script.Parent
  1582. else
  1583. magazineMax = script.Parent.MagazineMax
  1584. end
  1585. if script.Parent:FindFirstChild("Magazine") == nil then
  1586. magazine = Instance.new("NumberValue")
  1587. magazine.Name = "Magazine"
  1588. magazine.Value = 0
  1589. magazine.Parent = script.Parent
  1590. else
  1591. magazine = script.Parent.Magazine
  1592. end
  1593. if script.Parent:FindFirstChild("AmmoMax") == nil then
  1594. ammoMax = Instance.new("NumberValue")
  1595. ammoMax.Name = "AmmoMax"
  1596. ammoMax.Value = 10
  1597. ammoMax.Parent = script.Parent
  1598. else
  1599. ammoMax = script.Parent.AmmoMax
  1600. end
  1601. if script.Parent:FindFirstChild("Ammo") == nil then
  1602. ammo = Instance.new("NumberValue")
  1603. ammo.Name = "Ammo"
  1604. ammo.Value = script.Parent.AmmoMax.Value
  1605. ammo.Parent = script.Parent
  1606. else
  1607. ammo = script.Parent.Ammo
  1608. end
  1609. Player = script.Parent.Parent.Parent
  1610. makeParts("RightHolster")
  1611. script.Parent.Selected:connect(onSelected)
  1612. script.Parent.Deselected:connect(onDeselected)
  1613. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement