Advertisement
Guest User

RPG

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