Advertisement
Chungle16

Untitled

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