Advertisement
scripter123

Untitled

Mar 24th, 2015
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 113.19 KB | None | 0 0
  1. --[[
  2.  
  3. This is the main script for the gun
  4.  
  5. The only thing you should change is the settings
  6.  
  7. Don't change anything else or you might risk breaking the gun
  8.  
  9. If you have any questions / comments / concerns / sandwiches, message me
  10.  
  11. Enjoy!
  12. ______ ______ __ ______ _ ______
  13. / _/ _/ /_ __/_ _______/ /_ ____ / ____/_ _______(_)___ ____ / / /
  14. / // / / / / / / / ___/ __ \/ __ \/ /_ / / / / ___/ / __ \/ __ \ / // /
  15. / // / / / / /_/ / / / /_/ / /_/ / __/ / /_/ (__ ) / /_/ / / / / / // /
  16. / // / /_/ \__,_/_/ /_.___/\____/_/ \__,_/____/_/\____/_/ /_/ _/ // /
  17. /__/__/ /__/__/
  18.  
  19. --]]
  20.  
  21. repeat wait() until game.Players.LocalPlayer.Character
  22. repeat wait() until game.Players.LocalPlayer.Character:IsDescendantOf(game.Workspace)
  23. wait(1 / 20)
  24.  
  25. --------------------------------------------------------------------------------------
  26. --------------------[ IGNORE MODEL ]--------------------------------------------------
  27. --------------------------------------------------------------------------------------
  28.  
  29. local Ignore_Code = script:WaitForChild("Ignore_Code")
  30.  
  31. repeat wait() until Ignore_Code.Value ~= 0
  32.  
  33. local Ignore_Model = game.Workspace:WaitForChild("Ignore_Model_"..Ignore_Code.Value)
  34.  
  35. --------------------------------------------------------------------------------------
  36. --------------------[ CONSTANTS ]-----------------------------------------------------
  37. --------------------------------------------------------------------------------------
  38.  
  39. local Gun = script.Parent
  40. local Handle = Gun:WaitForChild("Handle")
  41. local AimPart = Gun:WaitForChild("AimPart")
  42. local Main = Gun:WaitForChild("Main")
  43.  
  44. local Ammo = Gun:WaitForChild("Ammo")
  45. local ClipSize = Gun:WaitForChild("ClipSize")
  46. local StoredAmmo = Gun:WaitForChild("StoredAmmo")
  47.  
  48. local LethalGrenades = Gun:WaitForChild("LethalGrenades")
  49. local TacticalGrenades = Gun:WaitForChild("TacticalGrenades")
  50.  
  51. local S = require(Gun:WaitForChild("SETTINGS"))
  52.  
  53. local Player = game.Players.LocalPlayer
  54. local Character = Player.Character
  55. local Humanoid = Character:WaitForChild("Humanoid")
  56. local Torso = Character:WaitForChild("Torso")
  57. local Head = Character:WaitForChild("Head")
  58. local HRP = Character:WaitForChild("HumanoidRootPart")
  59.  
  60. local Neck = Torso:WaitForChild("Neck")
  61.  
  62. local LArm = Character:WaitForChild("Left Arm")
  63. local RArm = Character:WaitForChild("Right Arm")
  64. local LLeg = Character:WaitForChild("Left Leg")
  65. local RLeg = Character:WaitForChild("Right Leg")
  66.  
  67. local M2 = Player:GetMouse()
  68. local Main_Gui = script:WaitForChild("Main_Gui")
  69.  
  70. local RS = game:GetService("RunService").RenderStepped
  71.  
  72. local Camera = game.Workspace.CurrentCamera
  73.  
  74. local ABS, HUGE, FLOOR, CEIL = math.abs, math.huge, math.floor, math.ceil
  75. local RAD, SIN, ATAN, COS = math.rad, math.sin, math.atan2, math.cos
  76. local VEC3 = Vector3.new
  77. local CF, CFANG = CFrame.new, CFrame.Angles
  78. local INSERT = table.insert
  79.  
  80. local MaxStamina = S.SprintTime * 60
  81. local MaxSteadyTime = S.ScopeSteadyTime * 60
  82.  
  83. local LethalIcons = {
  84. "http://www.roblox.com/asset/?id=194849880";
  85. "http://www.roblox.com/asset/?id=195727791";
  86. "http://www.roblox.com/asset/?id=195728137";
  87. }
  88.  
  89. local TacticalIcons = {
  90. "http://www.roblox.com/asset/?id=195728473";
  91. "http://www.roblox.com/asset/?id=195728693";
  92. }
  93.  
  94. local Ignore = {
  95. Character;
  96. Ignore_Model;
  97. }
  98.  
  99. local StanceOffset = {
  100. VEC3(0, 0, 0);
  101. VEC3(0, -1, 0);
  102. VEC3(0, -3, 0);
  103. }
  104.  
  105. local Shoulders = {
  106. Right = Torso:WaitForChild("Right Shoulder");
  107. Left = Torso:WaitForChild("Left Shoulder")
  108. }
  109.  
  110. local ArmC0 = {
  111. CF(-1.5, 0, 0) * CFANG(RAD(90), 0, 0);
  112. CF(1.5, 0, 0) * CFANG(RAD(90), 0, 0);
  113. }
  114.  
  115. local Sine = function(X)
  116. return SIN(RAD(X))
  117. end
  118.  
  119. local Linear = function(X)
  120. return (X / 90)
  121. end
  122.  
  123. --------------------------------------------------------------------------------------
  124. --------------------[ VARIABLES ]-----------------------------------------------------
  125. --------------------------------------------------------------------------------------
  126.  
  127. local Selected = false
  128.  
  129. local Idleing = false
  130. local Walking = false
  131. local Running = false
  132.  
  133. local Aimed = false
  134. local Aiming = false
  135.  
  136. local Reloading = false
  137. local BreakReload = false
  138.  
  139. local Knifing = false
  140. local ThrowingGrenade = false
  141.  
  142. local MB1_Down = false
  143.  
  144. local CanFire = true
  145.  
  146. local KnifeReady = true
  147.  
  148. local CanRun = true
  149. local RunTween = false
  150. local Run_Key_Pressed = false
  151. local ChargingStamina = false
  152.  
  153. local AimingIn = false
  154. local AimingOut = false
  155.  
  156. local Stamina = S.SprintTime * 60
  157. local CurrentSteadyTime = S.ScopeSteadyTime * 60
  158.  
  159. local CameraSteady = false
  160. local TakingBreath = false
  161.  
  162. local Grip = nil
  163. local Aimed_GripCF = nil
  164.  
  165. local Gui_Clone = nil
  166.  
  167. local CurrentSpread = S.Spread.Hipfire
  168. local CurrentRecoil = S.Recoil.Hipfire
  169.  
  170. local AmmoInClip = 0
  171.  
  172. local Stance = 0
  173. local StanceSway = 1
  174. local CameraSway = 1
  175.  
  176. local HeadRot = 0
  177. local ArmTilt = 0
  178.  
  179. local LastBeat = 0
  180.  
  181. local Parts = {}
  182.  
  183. local Connections = {}
  184.  
  185. local PrevNeckCF = {
  186. C0 = nil;
  187. C1 = nil;
  188. }
  189.  
  190. local Keys = {}
  191.  
  192. --------------------------------------------------------------------------------------
  193. --------------------[ PRE-LOADING ]---------------------------------------------------
  194. --------------------------------------------------------------------------------------
  195.  
  196. local ContentProvider = game:GetService("ContentProvider")
  197. ContentProvider:Preload(S.ExplosionSound)
  198. ContentProvider:Preload(S.KnifeMeshId)
  199. ContentProvider:Preload(S.KnifeTextureId)
  200. ContentProvider:Preload(S.BulletHoleTexture)
  201.  
  202. --------------------------------------------------------------------------------------
  203. --------------------[ ANIMATIONS ]----------------------------------------------------
  204. --------------------------------------------------------------------------------------
  205.  
  206. local AnimAng = {0, 0, 0, 0, 0}
  207.  
  208. local AnimCF = function(State, Ang)
  209. if State ~= "Running" then
  210. if (not Aimed) then
  211. if State == "Idleing" then
  212. return CF(
  213. RAD(SIN(Ang)) / 2 * StanceSway,
  214. 1 + RAD(SIN(Ang * 5 / 2)) / 2 * StanceSway, 0
  215. )
  216. elseif State == "Walking" then
  217. return CF(
  218. RAD(SIN(Ang)) * 2 * StanceSway,
  219. 1 + RAD(ABS(SIN(Ang))) * 2 * StanceSway, 0
  220. ) * CFANG(0, RAD(SIN(Ang)) / 3, 0)
  221. end
  222. elseif Aimed then
  223. if State == "Idleing" then
  224. return CF(
  225. RAD(SIN(Ang)) / 4 * StanceSway,
  226. 1 + RAD(SIN(Ang * 5 / 2)) / 4 * StanceSway, 0
  227. )
  228. elseif State == "Walking" then
  229. return CF(
  230. RAD(SIN(Ang)) / 3 * StanceSway,
  231. 1 + RAD(ABS(SIN(Ang))) / 3 * StanceSway, 0
  232. )
  233. end
  234. end
  235. elseif State == "Running" then
  236. return CF(
  237. SIN(Ang) / 6 * StanceSway,
  238. 0.9 + ABS(SIN(Ang)) / 5 * StanceSway, 0
  239. ) * CFANG(0, -RAD(SIN(Ang)) * 7, 0)
  240. end
  241. end
  242.  
  243. function Animate()
  244. local IsIdleing = false
  245. local IsWalking = false
  246. local IsRunning = false
  247. spawn(function()
  248. while Selected do
  249. IsIdleing = Idleing and (not Walking) and (not Reloading) and (not Knifing) and (not ThrowingGrenade) and Selected
  250. IsWalking = (not Idleing) and Walking and (not Running) and (not Reloading) and (not Knifing) and (not ThrowingGrenade) and Selected
  251. IsRunning = (not Idleing) and Walking and Running and (not Aiming) and (not Knifing) and (not ThrowingGrenade) and Selected
  252. RS:wait()
  253. end
  254. IsIdleing = false
  255. IsWalking = false
  256. IsRunning = false
  257. end)
  258. spawn(function()
  259. if S.PlayerAnimations then
  260. TweenJoint(LWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, 0.15)
  261. TweenJoint(RWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, 0.15)
  262. local PreviousArmTilt = ArmTilt
  263. while Selected do
  264. repeat RS:wait() until (ArmTilt ~= PreviousArmTilt) or (not Selected)
  265. if (not IsRunning) and (not Aimed) and (not Reloading) and (not Knifing) and (not ThrowingGrenade) and Selected then
  266. PreviousArmTilt = ArmTilt
  267. TweenJoint(LWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, 0.15)
  268. TweenJoint(RWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, 0.15)
  269. end
  270. RS:wait()
  271. end
  272. end
  273. end)
  274. spawn(function()
  275. while Selected do
  276. if IsIdleing then
  277. if (not Aimed) and (not Aiming) then
  278. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  279. UDim2.new(0, 70, 0, 70),
  280. UDim2.new(0, -35, 0, -35),
  281. Enum.EasingDirection.Out,
  282. Enum.EasingStyle.Linear,
  283. S.PlayerAnimations and 0.15 or 0,
  284. true
  285. )
  286. if S.PlayerAnimations then
  287. TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Sine, 0.15)
  288. TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Sine, 0.15)
  289. TweenJoint(AnimWeld, AnimCF("Idleing", AnimAng[1]), CF(), Sine, 0.15)
  290. TweenJoint(Grip, Grip.C0, CFANG(0, RAD(20), 0), Sine, 0.15)
  291. else
  292. if (not LWeld:FindFirstChild("TweenCode"))
  293. and (not RWeld:FindFirstChild("TweenCode"))
  294. and (not ABWeld:FindFirstChild("TweenCode"))
  295. and (not AnimWeld:FindFirstChild("TweenCode")) then
  296. LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_UnAimed.Left
  297. RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_UnAimed.Right
  298. AnimWeld.C0 = CF(0, 1, 0)
  299. Grip.C1 = CFANG(0, RAD(20), 0)
  300. end
  301. end
  302. elseif Aimed and (not Aiming) then
  303. if S.PlayerAnimations then
  304. TweenJoint(LWeld, ArmC0[1], S.ArmC1_Aimed.Left, Sine, 0.15)
  305. TweenJoint(RWeld, ArmC0[2], S.ArmC1_Aimed.Right, Sine, 0.15)
  306. TweenJoint(AnimWeld, AnimCF("Idleing", AnimAng[2]), CF(), Sine, 0.15)
  307. else
  308. if (not LWeld:FindFirstChild("TweenCode"))
  309. and (not RWeld:FindFirstChild("TweenCode"))
  310. and (not ABWeld:FindFirstChild("TweenCode"))
  311. and (not AnimWeld:FindFirstChild("TweenCode")) then
  312. LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_Aimed.Left
  313. RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_Aimed.Right
  314. AnimWeld.C0 = CF(0, 1, 0)
  315. Grip.C1 = Aimed_GripCF
  316. end
  317. end
  318. end
  319. if S.PlayerAnimations then
  320. wait(0.15)
  321. RunTween = false
  322. while IsIdleing do
  323. if (not LWeld:FindFirstChild("TweenCode"))
  324. and (not RWeld:FindFirstChild("TweenCode"))
  325. and (not ABWeld:FindFirstChild("TweenCode"))
  326. and (not AnimWeld:FindFirstChild("TweenCode")) then
  327. if (not Aimed) and (not Aiming) then
  328. AnimWeld.C0 = AnimCF("Idleing", AnimAng[1])
  329. AnimAng[1] = AnimAng[1] + 0.03 * StanceSway
  330. elseif Aimed and (not Aiming) then
  331. AnimWeld.C0 = AnimCF("Idleing", AnimAng[2])
  332. AnimAng[2] = AnimAng[2] + 0.015 * StanceSway
  333. end
  334. end
  335. RS:wait()
  336. end
  337. AnimAng[1], AnimAng[2] = 0, 0
  338. end
  339. end
  340. if IsWalking then
  341. if (not Aimed) and (not Aiming) then
  342. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  343. UDim2.new(0, 150, 0, 150),
  344. UDim2.new(0, -75, 0, -75),
  345. Enum.EasingDirection.Out,
  346. Enum.EasingStyle.Linear,
  347. S.PlayerAnimations and 0.15 or 0,
  348. true
  349. )
  350. if S.PlayerAnimations then
  351. TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Sine, 0.15)
  352. TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Sine, 0.15)
  353. TweenJoint(AnimWeld, AnimCF("Walking", AnimAng[3]), CF(), Sine, 0.15)
  354. TweenJoint(Grip, Grip.C0, CFANG(0, RAD(20), 0), Sine, 0.15)
  355. else
  356. if (not LWeld:FindFirstChild("TweenCode"))
  357. and (not RWeld:FindFirstChild("TweenCode"))
  358. and (not ABWeld:FindFirstChild("TweenCode"))
  359. and (not AnimWeld:FindFirstChild("TweenCode")) then
  360. LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_UnAimed.Left
  361. RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_UnAimed.Right
  362. AnimWeld.C0 = CF(0, 1, 0)
  363. Grip.C1 = CFANG(0, RAD(20), 0)
  364. end
  365. end
  366. elseif Aimed and (not Aiming) then
  367. if S.PlayerAnimations then
  368. TweenJoint(LWeld, ArmC0[1], S.ArmC1_Aimed.Left, Sine, 0.15)
  369. TweenJoint(RWeld, ArmC0[2], S.ArmC1_Aimed.Right, Sine, 0.15)
  370. TweenJoint(AnimWeld, AnimCF("Walking", AnimAng[4]), CF(), Sine, 0.15)
  371. else
  372. if (not LWeld:FindFirstChild("TweenCode"))
  373. and (not RWeld:FindFirstChild("TweenCode"))
  374. and (not ABWeld:FindFirstChild("TweenCode"))
  375. and (not AnimWeld:FindFirstChild("TweenCode")) then
  376. LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_Aimed.Left
  377. RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_Aimed.Right
  378. AnimWeld.C0 = CF(0, 1, 0)
  379. Grip.C1 = Aimed_GripCF
  380. end
  381. end
  382. end
  383. if S.PlayerAnimations then
  384. wait(0.15)
  385. RunTween = false
  386. while IsWalking do
  387. if (not LWeld:FindFirstChild("TweenCode"))
  388. and (not RWeld:FindFirstChild("TweenCode"))
  389. and (not ABWeld:FindFirstChild("TweenCode"))
  390. and (not AnimWeld:FindFirstChild("TweenCode"))then
  391. if (not Aimed) and (not Aiming) then
  392. AnimWeld.C0 = AnimCF("Walking", AnimAng[3])
  393. AnimAng[3] = AnimAng[3] + 0.15 * StanceSway
  394. elseif Aimed and (not Aiming) then
  395. AnimWeld.C0 = AnimCF("Walking", AnimAng[4])
  396. AnimAng[4] = AnimAng[4] + 0.1 * StanceSway
  397. end
  398. end
  399. RS:wait()
  400. end
  401. AnimAng[3], AnimAng[4] = 0, 0
  402. end
  403. end
  404. if IsRunning then
  405. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  406. UDim2.new(0, 200, 0, 200),
  407. UDim2.new(0, -100, 0, -100),
  408. Enum.EasingDirection.Out,
  409. Enum.EasingStyle.Linear,
  410. S.PlayerAnimations and 0.15 or 0,
  411. true
  412. )
  413. local LArmCF = CF(0, 0.7 - (SIN(AnimAng[5]) + 1)/15, 0)
  414. local LArmAng = CFANG(RAD(ABS(COS(AnimAng[5]))) * 10 + RAD(35), RAD(-30), RAD((SIN(AnimAng[5]) + 1) * 15 - 40))
  415. local RArmCF = CF(0, (SIN(AnimAng[5]) + 1)/2, 0)
  416. local RArmAng = CFANG(RAD(ABS(COS(AnimAng[5]))) * 10 + RAD(20), 0, RAD(50 + (SIN(AnimAng[5]) + 1) * 5))
  417. if S.PlayerAnimations then
  418. TweenJoint(LWeld, ArmC0[1], LArmCF * LArmAng, Sine, 0.15)
  419. TweenJoint(RWeld, ArmC0[2], RArmCF * RArmAng, Sine, 0.15)
  420. TweenJoint(AnimWeld, AnimCF("Running", AnimAng[5]), CF(), Sine, 0.15)
  421. TweenJoint(Grip, Grip.C0, CFANG(0, RAD(-5), 0), Sine, 0.15)
  422. else
  423. LWeld.C0, LWeld.C1 = ArmC0[1], LArmCF * LArmAng
  424. RWeld.C0, RWeld.C1 = ArmC0[2], RArmCF * RArmAng
  425. AnimWeld.C0 = CF(0, 0.9, 0)
  426. Grip.C1 = CFANG(0, RAD(-5), 0)
  427. end
  428. if S.PlayerAnimations then
  429. RunTween = true
  430. wait(0.15)
  431. while IsRunning do
  432. if (not Aiming) then
  433. AnimWeld.C0 = AnimCF("Running", AnimAng[5])
  434. AnimAng[5] = AnimAng[5] + 0.18
  435. end
  436. RS:wait()
  437. end
  438. AnimAng[5] = 0
  439. end
  440. end
  441. RS:wait()
  442. end
  443. end)
  444. end
  445.  
  446. --------------------------------------------------------------------------------------
  447. --------------------[ GUN SETUP ]-----------------------------------------------------
  448. --------------------------------------------------------------------------------------
  449.  
  450. Gun.Name = S.GunName
  451. Gun.ToolTip = S.Description
  452.  
  453. --------------------------------------------------------------------------------------
  454. --------------------[ PRE-CONNECTIONS ]-----------------------------------------------
  455. --------------------------------------------------------------------------------------
  456.  
  457. RS:connect(function()
  458. local Forward = (Keys["w"] or Keys[string.char(17)])
  459. local Backward = (Keys["s"] or Keys[string.char(18)])
  460. local Right = (Keys["d"] or Keys[string.char(19)])
  461. local Left = (Keys["a"] or Keys[string.char(20)])
  462.  
  463. if (Forward or Backward or Right or Left) then
  464. Walking, Idleing = true, false
  465. elseif (not (Forward and Backward and Right and Left)) then
  466. Walking, Idleing = false, true
  467. end
  468. end)
  469.  
  470. M2.KeyDown:connect(function(Key) Keys[Key] = true end)
  471. M2.KeyUp:connect(function(Key) Keys[Key] = false end)
  472.  
  473. --------------------------------------------------------------------------------------
  474. --------------------[ WELDING ]-------------------------------------------------------
  475. --------------------------------------------------------------------------------------
  476.  
  477. spawn(function()
  478. for _, v in pairs(Gun:GetChildren()) do
  479. if v:IsA("BasePart") and v ~= Handle then
  480. if v:FindFirstChild("MainWeld") then v.MainWeld:Destroy() end
  481. if (not v:FindFirstChild("WeldCF")) then
  482. local WeldCF = Instance.new("CFrameValue")
  483. WeldCF.Name = "WeldCF"
  484. WeldCF.Value = Handle.CFrame:toObjectSpace(v.CFrame)
  485. WeldCF.Parent = v
  486. end
  487. INSERT(Parts, {Obj = v, Weld = nil})
  488. v.Anchored = false
  489. end
  490. end
  491. Handle.Anchored = false
  492. end)
  493.  
  494. --------------------------------------------------------------------------------------
  495. --------------------[ MAIN PROGRAM ]--------------------------------------------------
  496. --------------------------------------------------------------------------------------
  497.  
  498. --------------------[ ARM CREATION FUNCTION ]-----------------------------------------
  499.  
  500. function CreateArms()
  501. local Arms = {}
  502. for i = 0, 1 do
  503. local ArmModel = Instance.new("Model")
  504. ArmModel.Name = "ArmModel"
  505.  
  506. local Arm = Instance.new("Part")
  507. Arm.BrickColor = (S.FakeArmRealBodyColor and (i == 0 and LArm.BrickColor or RArm.BrickColor) or S.FakeArmColor)
  508. Arm.Transparency = S.FakeArmTransparency
  509. Arm.Name = "Arm"
  510. Arm.CanCollide = false
  511. Arm.Size = VEC3(1, 2, 1)
  512. Arm.Parent = ArmModel
  513. local ArmMesh = Instance.new("SpecialMesh")
  514. ArmMesh.MeshId = "rbxasset://fonts//rightarm.mesh"
  515. ArmMesh.MeshType = Enum.MeshType.FileMesh
  516. ArmMesh.Scale = VEC3(0.65, 1, 0.65)
  517. ArmMesh.Parent = Arm
  518.  
  519. local Sleeve1 = Instance.new("Part")
  520. Sleeve1.BrickColor = BrickColor.new("Sand green")
  521. Sleeve1.Name = "Sleeve1"
  522. Sleeve1.CanCollide = false
  523. Sleeve1.Size = VEC3(1, 2, 1)
  524. Sleeve1.Parent = ArmModel
  525. local Sleeve1Mesh = Instance.new("BlockMesh")
  526. Sleeve1Mesh.Offset = VEC3(0, 0.66, 0)
  527. Sleeve1Mesh.Scale = VEC3(0.656, 0.35, 0.656)
  528. Sleeve1Mesh.Parent = Sleeve1
  529. local Sleeve1Weld = Instance.new("Weld")
  530. Sleeve1Weld.Part0 = Arm
  531. Sleeve1Weld.Part1 = Sleeve1
  532. Sleeve1Weld.Parent = Arm
  533.  
  534. local Sleeve2 = Instance.new("Part")
  535. Sleeve2.BrickColor = BrickColor.new("Sand green")
  536. Sleeve2.Name = "Sleeve2"
  537. Sleeve2.CanCollide = false
  538. Sleeve2.Size = VEC3(1, 2, 1)
  539. Sleeve2.Parent = ArmModel
  540. local Sleeve2Mesh = Instance.new("BlockMesh")
  541. Sleeve2Mesh.Offset = VEC3(0, 0.46, 0)
  542. Sleeve2Mesh.Scale = VEC3(0.75, 0.1, 0.75)
  543. Sleeve2Mesh.Parent = Sleeve2
  544. local Sleeve2Weld = Instance.new("Weld")
  545. Sleeve2Weld.Part0 = Arm
  546. Sleeve2Weld.Part1 = Sleeve2
  547. Sleeve2Weld.Parent = Arm
  548.  
  549. local Glove1 = Instance.new("Part")
  550. Glove1.BrickColor = BrickColor.new("Black")
  551. Glove1.Name = "Glove1"
  552. Glove1.CanCollide = false
  553. Glove1.Size = VEC3(1, 2, 1)
  554. Glove1.Parent = ArmModel
  555. local Glove1Mesh = Instance.new("BlockMesh")
  556. Glove1Mesh.Offset = VEC3(0, -0.4, 0)
  557. Glove1Mesh.Scale = VEC3(0.657, 0.205, 0.657)
  558. Glove1Mesh.Parent = Glove1
  559. local Glove1Weld = Instance.new("Weld")
  560. Glove1Weld.Part0 = Arm
  561. Glove1Weld.Part1 = Glove1
  562. Glove1Weld.Parent = Arm
  563.  
  564. local Glove2 = Instance.new("Part")
  565. Glove2.BrickColor = BrickColor.new("Black")
  566. Glove2.Name = "Glove2"
  567. Glove2.CanCollide = false
  568. Glove2.Size = VEC3(1, 2, 1)
  569. Glove2.Parent = ArmModel
  570. local Glove2Mesh = Instance.new("BlockMesh")
  571. Glove2Mesh.Offset = VEC3(0, -0.335, 0)
  572. Glove2Mesh.Scale = VEC3(0.69, 0.105, 0.69)
  573. Glove2Mesh.Parent = Glove2
  574. local Glove2Weld = Instance.new("Weld")
  575. Glove2Weld.Part0 = Arm
  576. Glove2Weld.Part1 = Glove2
  577. Glove2Weld.Parent = Arm
  578.  
  579. local Glove3 = Instance.new("Part")
  580. Glove3.BrickColor = BrickColor.new("Black")
  581. Glove3.Name = "Glove3"
  582. Glove3.CanCollide = false
  583. Glove3.Size = VEC3(1, 2, 1)
  584. Glove3.Parent = ArmModel
  585. local Glove3Mesh = Instance.new("BlockMesh")
  586. Glove3Mesh.Offset = VEC3(0.2 * ((i * 2) - 1), -0.8, 0)
  587. Glove3Mesh.Scale = VEC3(0.257, 0.205, 0.657)
  588. Glove3Mesh.Parent = Glove3
  589. local Glove3Weld = Instance.new("Weld")
  590. Glove3Weld.Part0 = Arm
  591. Glove3Weld.Part1 = Glove3
  592. Glove3Weld.Parent = Arm
  593.  
  594. table.insert(Arms, {Model = ArmModel, ArmPart = Arm})
  595. end
  596. return Arms
  597. end
  598.  
  599. --------------------[ MATH FUNCTIONS ]------------------------------------------------
  600.  
  601. function NumLerp(A, B, Alpha)
  602. return (A + ((B - A) * Alpha))
  603. end
  604.  
  605. function RAND(Min, Max, Accuracy)
  606. local Inverse = 1 / (Accuracy or 1)
  607. return (math.random(Min * Inverse, Max * Inverse) / Inverse)
  608. end
  609.  
  610. --------------------[ TWEEN FUNCTIONS ]-----------------------------------------------
  611.  
  612. function TweenJoint(Joint, NewC0, NewC1, Alpha, Duration)
  613. coroutine.resume(coroutine.create(function()
  614. local TweenIndicator = nil --At the current moment, this is how the script determines whether the function is already tweening a joint
  615. local NewCode = math.random(-1e9, 1e9) --This creates a random code between -1000000000 and 1000000000
  616. if (not Joint:FindFirstChild("TweenCode")) then --If the joint isn't being tweened, then
  617. TweenIndicator = Instance.new("IntValue")
  618. TweenIndicator.Name = "TweenCode"
  619. TweenIndicator.Value = NewCode
  620. TweenIndicator.Parent = Joint
  621. else
  622. TweenIndicator = Joint.TweenCode
  623. TweenIndicator.Value = NewCode --If the joint is already being tweened, this will change the code, and the tween loop will stop
  624. end
  625. local MatrixCFrame = function(CFPos, CFTop, CFBack)
  626. local CFRight = CFTop:Cross(CFBack)
  627. return CF(
  628. CFPos.x, CFPos.y, CFPos.z,
  629. CFRight.x, CFTop.x, CFBack.x,
  630. CFRight.y, CFTop.y, CFBack.y,
  631. CFRight.z, CFTop.z, CFBack.z
  632. )
  633. end
  634. local LerpCF = function(StartCF, EndCF, Alpha)
  635. local StartTop = (StartCF * CFANG(RAD(90), 0, 0)).lookVector
  636. local StartBack = -StartCF.lookVector
  637. local EndTop = (EndCF * CFANG(RAD(90), 0, 0)).lookVector
  638. local EndBack = -EndCF.lookVector
  639. local StartPos = StartCF.p
  640. local EndPos = EndCF.p
  641. local NewCF = MatrixCFrame(
  642. StartPos:lerp(EndPos, Alpha),
  643. StartTop:lerp(EndTop, Alpha),
  644. StartBack:lerp(EndBack, Alpha)
  645. )
  646. return NewCF
  647. end
  648. local StartC0 = Joint.C0
  649. local StartC1 = Joint.C1
  650. local X = 0
  651. while true do
  652. local NewX = X + math.min(1.5 / math.max(Duration, 0), 90)
  653. X = (NewX > 90 and 90 or NewX)
  654. if TweenIndicator.Value ~= NewCode then break end --This makes sure that another tween wasn't called on the same joint
  655. if (not Selected) then break end --This stops the tween if the tool is deselected
  656. if NewC0 then Joint.C0 = LerpCF(StartC0, NewC0, Alpha(X)) end
  657. if NewC1 then Joint.C1 = LerpCF(StartC1, NewC1, Alpha(X)) end
  658. if X == 90 then break end
  659. RS:wait() --This makes the for loop step every 1/60th of a second
  660. end
  661. if TweenIndicator.Value == NewCode then --If this tween functions was the last one called on a joint then it will remove the code
  662. TweenIndicator:Destroy()
  663. end
  664. end))
  665. end
  666.  
  667. function RotCamera(RotX, RotY, SmoothRot, Duration)
  668. spawn(function()
  669. if SmoothRot then
  670. local TweenIndicator = nil
  671. local NewCode = math.random(-1e9, 1e9)
  672. if (not Camera:FindFirstChild("TweenCode")) then
  673. TweenIndicator = Instance.new("IntValue")
  674. TweenIndicator.Name = "TweenCode"
  675. TweenIndicator.Value = NewCode
  676. TweenIndicator.Parent = Camera
  677. else
  678. TweenIndicator = Camera.TweenCode
  679. TweenIndicator.Value = NewCode
  680. end
  681.  
  682. local Step = math.min(1.5 / math.max(Duration, 0), 90)
  683. local X = 0
  684. while true do
  685. local NewX = X + Step
  686. X = (NewX > 90 and 90 or NewX)
  687. if TweenIndicator.Value ~= NewCode then break end
  688. if (not Selected) then break end
  689.  
  690. local CamRot = Camera.CoordinateFrame - Camera.CoordinateFrame.p
  691. local CamDist = (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude
  692. local NewCamCF = CF(Camera.Focus.p) * CamRot * CFANG(RotX / (90 / Step), RotY / (90 / Step), 0)
  693. Camera.CoordinateFrame = CF(NewCamCF.p, NewCamCF.p + NewCamCF.lookVector) * CF(0, 0, CamDist)
  694.  
  695. if X == 90 then break end
  696. RS:wait()
  697. end
  698.  
  699. if TweenIndicator.Value == NewCode then
  700. TweenIndicator:Destroy()
  701. end
  702. else
  703. local CamRot = Camera.CoordinateFrame - Camera.CoordinateFrame.p
  704. local CamDist = (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude
  705. local NewCamCF = CF(Camera.Focus.p) * CamRot * CFANG(RotX, RotY, 0)
  706. Camera.CoordinateFrame = CF(NewCamCF.p, NewCamCF.p + NewCamCF.lookVector) * CF(0, 0, CamDist)
  707. end
  708. end)
  709. end
  710.  
  711. --------------------[ GUI SETUP FUNCTION ]--------------------------------------------
  712.  
  713. function ConvertKey(Key)
  714. if Key == string.char(8) then
  715. return "BKSPCE"
  716. elseif Key == string.char(9) then
  717. return "TAB"
  718. elseif Key == string.char(13) then
  719. return "ENTER"
  720. elseif Key == string.char(17) then
  721. return "UP"
  722. elseif Key == string.char(18) then
  723. return "DOWN"
  724. elseif Key == string.char(19) then
  725. return "RIGHT"
  726. elseif Key == string.char(20) then
  727. return "LEFT"
  728. elseif Key == string.char(22) then
  729. return "HOME"
  730. elseif Key == string.char(23) then
  731. return "END"
  732. elseif Key == string.char(27) then
  733. return "F2"
  734. elseif Key == string.char(29) then
  735. return "F4"
  736. elseif Key == string.char(30) then
  737. return "F5"
  738. elseif Key == string.char(32) or Key == " " then
  739. return "F7"
  740. elseif Key == string.char(33) or Key == "!" then
  741. return "F8"
  742. elseif Key == string.char(34) or Key == '"' then
  743. return "F9"
  744. elseif Key == string.char(35) or Key == "#" then
  745. return "F10"
  746. elseif Key == string.char(37) or Key == "%" then
  747. return "F12"
  748. elseif Key == string.char(47) or Key == "/" then
  749. return "R-SHIFT"
  750. elseif Key == string.char(48) or Key == "0" then
  751. return "L-SHIFT"
  752. elseif Key == string.char(49) or Key == "1" then
  753. return "R-CTRL"
  754. elseif Key == string.char(50) or Key == "2" then
  755. return "L-CTRL"
  756. elseif Key == string.char(51) or Key == "3" then
  757. return "R-ALT"
  758. elseif Key == string.char(52) or Key == "4" then
  759. return "L-ALT"
  760. else
  761. return string.upper(Key)
  762. end
  763. end
  764.  
  765. function CreateControlFrame(Key, Desc, Num)
  766. local Controls = Gui_Clone:WaitForChild("HUD"):WaitForChild("Controls")
  767.  
  768. local C = Instance.new("Frame")
  769. C.BackgroundTransparency = ((Num % 2) == 1 and 0.7 or 1)
  770. C.BorderSizePixel = 0
  771. C.Name = "C"..Num
  772. C.Position = UDim2.new(0, 0, 0, Num * 20)
  773. C.Size = UDim2.new(1, 0, 0, 20)
  774.  
  775. local K = Instance.new("TextLabel")
  776. K.BackgroundTransparency = 1
  777. K.Name = "Key"
  778. K.Size = UDim2.new(0, 45, 1, 0)
  779. K.Font = Enum.Font.ArialBold
  780. K.FontSize = Enum.FontSize.Size14
  781. K.Text = Key
  782. K.TextColor3 = Color3.new(1, 1, 1)
  783. K.TextScaled = (string.len(Key) > 5)
  784. K.TextWrapped = (string.len(Key) > 5)
  785. K.Parent = C
  786.  
  787. local D = Instance.new("TextLabel")
  788. D.BackgroundTransparency = 1
  789. D.Name = "Desc"
  790. D.Position = UDim2.new(0, 50, 0, 0)
  791. D.Size = UDim2.new(1, -50, 1, 0)
  792. D.Font = Enum.Font.ArialBold
  793. D.FontSize = Enum.FontSize.Size14
  794. D.Text = "- "..Desc
  795. D.TextColor3 = Color3.new(1, 1, 1)
  796. D.TextXAlignment = Enum.TextXAlignment.Left
  797. D.Parent = C
  798.  
  799. C.Parent = Controls
  800. end
  801.  
  802. function SetUpGui()
  803. local HUD = Gui_Clone:WaitForChild("HUD")
  804. local Scope = Gui_Clone:WaitForChild("Scope")
  805. local Grenades = HUD:WaitForChild("Grenades")
  806. local Controls = HUD:WaitForChild("Controls")
  807. local CurrentNum = 1
  808.  
  809. if S.CanChangeStance then
  810. local Dive = (S.DolphinDive and " / Dive" or "")
  811. CreateControlFrame(ConvertKey(S.LowerStanceKey), "Lower Stance"..Dive, CurrentNum)
  812. CurrentNum = CurrentNum + 1
  813.  
  814. CreateControlFrame(ConvertKey(S.RaiseStanceKey), "Raise Stance", CurrentNum)
  815. CurrentNum = CurrentNum + 1
  816. end
  817.  
  818. CreateControlFrame(ConvertKey(S.ReloadKey), "Reload", CurrentNum)
  819. CurrentNum = CurrentNum + 1
  820.  
  821. if S.CanKnife then
  822. CreateControlFrame(ConvertKey(S.KnifeKey), "Knife", CurrentNum)
  823. CurrentNum = CurrentNum + 1
  824. end
  825.  
  826. if S.Throwables then
  827. CreateControlFrame(ConvertKey(S.LethalGrenadeKey), "Throw Lethal", CurrentNum)
  828. CurrentNum = CurrentNum + 1
  829.  
  830. CreateControlFrame(ConvertKey(S.TacticalGrenadeKey), "Throw Tactical", CurrentNum)
  831. CurrentNum = CurrentNum + 1
  832. else
  833. Grenades.Visible = false
  834. HUD.Position = UDim2.new(1, -200, 1, -100)
  835. HUD.Size = UDim2.new(0, 175, 0, 50)
  836. end
  837.  
  838. CreateControlFrame(ConvertKey(S.SprintKey), "Sprint", CurrentNum)
  839. CurrentNum = CurrentNum + 1
  840.  
  841. if S.ADSKey ~= "" then
  842. local Hold = (S.HoldMouseOrKeyToADS and "HOLD " or "")
  843. CreateControlFrame(Hold..ConvertKey(S.ADSKey).." OR R-MOUSE", "Aim Down Sights", CurrentNum)
  844. CurrentNum = CurrentNum + 1
  845. end
  846.  
  847. Controls.Size = UDim2.new(1, 0, 0, CurrentNum * 20)
  848. Controls.Position = UDim2.new(0, 0, 0, -(CurrentNum * 20) - 80)
  849.  
  850. if S.GuiScope then
  851. Scope:WaitForChild("Img").Image = S.GuiId
  852. Scope:WaitForChild("Steady").Text = "Hold "..ConvertKey(S.ScopeSteadyKey).." to Steady"
  853. end
  854.  
  855. if HUD:FindFirstChild("Co") then
  856. HUD.Co:Destroy()
  857. end
  858. local Co = Instance.new("TextLabel")
  859. Co.BackgroundTransparency = 1
  860. Co.Name = "Co"
  861. Co.Position = UDim2.new(0, 0, 1, 5)
  862. Co.Size = UDim2.new(1, 0, 0, 20)
  863. Co.Font = Enum.Font.ArialBold
  864. Co.FontSize = Enum.FontSize.Size14
  865. Co.Text = ("noisuFobruT yb detpircs tiK nuG"):reverse()
  866. Co.TextColor3 = Color3.new(1, 1, 0)
  867. Co.TextStrokeTransparency = 0
  868. Co.TextXAlignment = Enum.TextXAlignment.Right
  869. Co.Parent = HUD
  870.  
  871. HUD:WaitForChild("Grenades"):WaitForChild("Lethals"):WaitForChild("Icon").Image = LethalIcons[S.LethalGrenadeType]
  872. HUD:WaitForChild("Grenades"):WaitForChild("Tacticals"):WaitForChild("Icon").Image = TacticalIcons[S.TacticalGrenadeType]
  873. end
  874.  
  875. --------------------[ FIRING FUNCTIONS ]----------------------------------------------
  876.  
  877. function Fire_Gun()
  878. local FireSound = Handle:FindFirstChild("FireSound")
  879. local FlashGui = Main:FindFirstChild("FlashGui")
  880. local FlashFX = Main:FindFirstChild("FlashFX")
  881.  
  882. if FireSound then FireSound:Play() end
  883.  
  884. local MockSpread = (
  885. ((not Aimed) and CurrentSpread <= S.Spread.Max and Idleing)
  886. and CurrentSpread * S.Spread.Multiplier or CurrentSpread
  887. )
  888. CurrentSpread = (MockSpread >= S.Spread.Max and S.Spread.Max or MockSpread)
  889.  
  890. ----------------------------------------------------------------------------------
  891. for _ = 1, (S.GunType.Shot and S.ShotAmount or 1) do
  892. local BSpread = CFANG(
  893. RAD(RAND(-CurrentSpread, CurrentSpread) / 20),
  894. RAD(RAND(-CurrentSpread, CurrentSpread) / 20),
  895. RAD(RAND(-CurrentSpread, CurrentSpread) / 20)
  896. )
  897. local OriginCF = (Aimed and (S.GuiScope and Head.CFrame or Handle.CFrame) or Head.CFrame)
  898. local OriginPos = Main.CFrame.p
  899. local Direction = (CF(OriginCF.p, OriginCF.p + OriginCF.lookVector) * BSpread).lookVector
  900.  
  901. if S.InstantHit then
  902. local HitObj, HitPos = AdvRayCast(Main.CFrame.p, Direction, S.BulletRange)
  903. local HitHumanoid = nil
  904. if HitObj then
  905. if S.GunType.Explosive then
  906. if S.ExplosionSound ~= "" then
  907. local SoundPart = Instance.new("Part")
  908. SoundPart.Transparency = 1
  909. SoundPart.Anchored = true
  910. SoundPart.CanCollide = false
  911. SoundPart.CFrame = CFrame.new(HitPos)
  912. SoundPart.Parent = game.Workspace
  913.  
  914. local Sound = Instance.new("Sound")
  915. Sound.Pitch = S.ExplosionSoundPitch
  916. Sound.SoundId = S.ExplosionSound
  917. Sound.Volume = S.ExplosionSoundVolume
  918. Sound.Parent = SoundPart
  919. Sound:Play()
  920.  
  921. delay(1 / 20, function()
  922. SoundPart:Destroy()
  923. end)
  924. end
  925. CreateBulletHole(HitPos, HitObj)
  926. CreateShockwave(HitPos, S.ExplosionRadius)
  927. local E = Instance.new("Explosion")
  928. E.BlastPressure = S.ExplosionPressure
  929. E.BlastRadius = S.ExplosionRadius
  930. E.DestroyJointRadiusPercent = (S.RangeBasedDamage and 0 or 1)
  931. E.ExplosionType = S.ExplosionType
  932. E.Position = HitPos
  933. E.Hit:connect(function(HObj, HDist)
  934. if HObj.Name == "Torso" and (not HObj:IsDescendantOf(Character)) then
  935. if S.RangeBasedDamage then
  936. local Dir = (HObj.Position - HitPos).unit
  937. local H, P = AdvRayCast(HitPos - Dir, Dir, 999)
  938. local RayHitHuman = H:IsDescendantOf(HObj.Parent)
  939. if (S.RayCastExplosions and RayHitHuman) or (not S.RayCastExplosions) then
  940. local HitHumanoid = FindFirstClass(HObj.Parent, "Humanoid")
  941. if HitHumanoid and HitHumanoid.Health > 0 and IsEnemy(HitHumanoid) then
  942. local DistFactor = HDist / S.ExplosionRadius
  943. local DistInvert = math.max(1 - DistFactor,0)
  944. local NewDamage = DistInvert * S.Damage
  945.  
  946. local CreatorTag = Instance.new("ObjectValue")
  947. CreatorTag.Value = Player
  948. CreatorTag.Name = "creator"
  949. CreatorTag.Parent = HitHumanoid
  950. HitHumanoid:TakeDamage(NewDamage)
  951. MarkHit()
  952. end
  953. end
  954. else
  955. local HitHumanoid = FindFirstClass(HObj.Parent, "Humanoid")
  956. if HitHumanoid and HitHumanoid.Health > 0 and IsEnemy(HitHumanoid) then
  957. local CreatorTag = Instance.new("ObjectValue")
  958. CreatorTag.Value = Player
  959. CreatorTag.Name = "creator"
  960. CreatorTag.Parent = HitHumanoid
  961. MarkHit()
  962. end
  963. end
  964. end
  965. end)
  966. E.Parent = game.Workspace
  967. else
  968. HitHumanoid = Damage(HitObj, HitPos)
  969. end
  970. end
  971. local FinalHitPos = HitPos
  972. if S.Penetration > 0 and (not S.GunType.Explosive) then
  973. FinalHitPos = PenetrateWall(HitPos, Direction, HitHumanoid, OriginPos)
  974. end
  975. if S.BulletTrail and S.TrailTransparency ~= 1 then
  976. local Trail = Instance.new("Part")
  977. Trail.BrickColor = S.TrailColor
  978. Trail.Transparency = S.TrailTransparency
  979. Trail.Anchored = true
  980. Trail.CanCollide = false
  981. Trail.Size = VEC3(1, 1, 1)
  982. local Mesh = Instance.new("BlockMesh")
  983. Mesh.Offset = VEC3(0, 0, -(FinalHitPos - OriginPos).magnitude / 2)
  984. Mesh.Scale = VEC3(S.TrailThickness, S.TrailThickness, (FinalHitPos - OriginPos).magnitude)
  985. Mesh.Parent = Trail
  986. Trail.Parent = Gun_Ignore
  987. Trail.CFrame = CF(OriginPos, FinalHitPos)
  988. delay(S.TrailVisibleTime, function()
  989. if S.TrailDisappearTime > 0 then
  990. local X = 0
  991. while true do
  992. if X == 90 then break end
  993. if (not Selected) then break end
  994. local NewX = X + (1.5 / S.TrailDisappearTime)
  995. X = (NewX > 90 and 90 or NewX)
  996. local Alpha = X / 90
  997. Trail.Transparency = NumLerp(S.TrailTransparency, 1, Alpha)
  998. RS:wait()
  999. end
  1000. Trail:Destroy()
  1001. else
  1002. Trail:Destroy()
  1003. end
  1004. end)
  1005. end
  1006. else
  1007. local Bullet = CreateBullet(Direction)
  1008. local LastPos = Main.CFrame.p
  1009. local TotalDistTraveled = 0
  1010. local HitHumanoid = nil
  1011. spawn(function()
  1012. while true do
  1013. RS:wait()
  1014. if TotalDistTraveled >= S.BulletRange then
  1015. Bullet:Destroy()
  1016. break
  1017. end
  1018. local DistTraveled = (Bullet.Position - LastPos).magnitude
  1019. local HitObj, HitPos = AdvRayCast(LastPos, (Bullet.Position - LastPos).unit, DistTraveled)
  1020. if HitObj then
  1021. if S.GunType.Explosive then
  1022. if S.ExplosionSound ~= "" then
  1023. local Sound = Instance.new("Sound")
  1024. Sound.Pitch = S.ExplosionSoundPitch
  1025. Sound.SoundId = S.ExplosionSound
  1026. Sound.Volume = S.ExplosionSoundVolume
  1027. Sound.Parent = Bullet
  1028. Sound:Play()
  1029. end
  1030. CreateBulletHole(HitPos, HitObj)
  1031. CreateShockwave(HitPos, S.ExplosionRadius)
  1032. local E = Instance.new("Explosion")
  1033. E.BlastPressure = S.ExplosionPressure
  1034. E.BlastRadius = S.ExplosionRadius
  1035. E.DestroyJointRadiusPercent = (S.RangeBasedDamage and 0 or 1)
  1036. E.ExplosionType = S.ExplosionType
  1037. E.Position = HitPos
  1038. E.Hit:connect(function(HObj, HDist)
  1039. if HObj.Name == "Torso" and (not HObj:IsDescendantOf(Character)) then
  1040. if S.RangeBasedDamage then
  1041. local Dir = (HObj.Position - HitPos).unit
  1042. local H, P = AdvRayCast(HitPos - Dir, Dir, 999)
  1043. local RayHitHuman = H:IsDescendantOf(HObj.Parent)
  1044. if (S.RayCastExplosions and RayHitHuman) or (not S.RayCastExplosions) then
  1045. local HitHumanoid = FindFirstClass(HObj.Parent, "Humanoid")
  1046. if HitHumanoid and HitHumanoid.Health > 0 and IsEnemy(HitHumanoid) then
  1047. local DistFactor = HDist / S.ExplosionRadius
  1048. local DistInvert = math.max(1 - DistFactor,0)
  1049. local NewDamage = DistInvert * S.Damage
  1050.  
  1051. local CreatorTag = Instance.new("ObjectValue")
  1052. CreatorTag.Value = Player
  1053. CreatorTag.Name = "creator"
  1054. CreatorTag.Parent = HitHumanoid
  1055. HitHumanoid:TakeDamage(NewDamage)
  1056. MarkHit()
  1057. end
  1058. end
  1059. else
  1060. local HitHumanoid = FindFirstClass(HObj.Parent, "Humanoid")
  1061. if HitHumanoid and HitHumanoid.Health > 0 and IsEnemy(HitHumanoid) then
  1062. local CreatorTag = Instance.new("ObjectValue")
  1063. CreatorTag.Value = Player
  1064. CreatorTag.Name = "creator"
  1065. CreatorTag.Parent = HitHumanoid
  1066. MarkHit()
  1067. end
  1068. end
  1069. end
  1070. end)
  1071. E.Parent = game.Workspace
  1072. else
  1073. HitHumanoid = Damage(HitObj, HitPos)
  1074. end
  1075. if S.Penetration > 0 and (not S.GunType.Explosive) then
  1076. PenetrateWall(HitPos, (Bullet.Position - LastPos).unit, HitHumanoid, OriginPos, Bullet)
  1077. else
  1078. Bullet:Destroy()
  1079. end
  1080. break
  1081. else
  1082. LastPos = Bullet.Position
  1083. TotalDistTraveled = TotalDistTraveled + DistTraveled
  1084. end
  1085. end
  1086. end)
  1087.  
  1088. if S.BulletTrail and S.TrailTransparency ~= 1 then
  1089. spawn(function()
  1090. local LastPos2 = nil
  1091. while true do
  1092. if LastPos2 then
  1093. if (not Bullet:IsDescendantOf(game)) then break end
  1094. Bullet.CFrame = CFrame.new(Bullet.CFrame.p, Bullet.CFrame.p + Bullet.Velocity)
  1095. local Trail = Instance.new("Part")
  1096. Trail.BrickColor = S.TrailColor
  1097. Trail.Transparency = S.TrailTransparency
  1098. Trail.Anchored = true
  1099. Trail.CanCollide = false
  1100. Trail.Size = VEC3(1, 1, 1)
  1101. local Mesh = Instance.new("BlockMesh")
  1102. Mesh.Offset = VEC3(0, 0, -(Bullet.Position - LastPos2).magnitude / 2)
  1103. Mesh.Scale = VEC3(S.TrailThickness, S.TrailThickness, (Bullet.Position - LastPos2).magnitude)
  1104. Mesh.Parent = Trail
  1105. Trail.Parent = Gun_Ignore
  1106. Trail.CFrame = CF(LastPos2, Bullet.Position)
  1107. delay(S.TrailVisibleTime, function()
  1108. if S.TrailDisappearTime > 0 then
  1109. local X = 0
  1110. while true do
  1111. if X == 90 then break end
  1112. if (not Selected) then break end
  1113. local NewX = X + (1.5 / S.TrailDisappearTime)
  1114. X = (NewX > 90 and 90 or NewX)
  1115. local Alpha = X / 90
  1116. Trail.Transparency = NumLerp(S.TrailTransparency, 1, Alpha)
  1117. RS:wait()
  1118. end
  1119. Trail:Destroy()
  1120. else
  1121. Trail:Destroy()
  1122. end
  1123. end)
  1124. LastPos2 = Bullet.Position
  1125. else
  1126. LastPos2 = Main.CFrame.p
  1127. end
  1128. RS:wait()
  1129. end
  1130. end)
  1131. end
  1132. end
  1133. end
  1134.  
  1135. ----------------------------------------------------------------------------------
  1136.  
  1137. local RecoilX = RAD(CurrentRecoil * RAND(1, 1.5, 0.1)) * StanceSway
  1138. local RecoilY = RAD(CurrentRecoil * RAND(-2, 2, 0.1)) * StanceSway
  1139. RotCamera(RecoilX, RecoilY, true, 0.06)
  1140. delay(0.05, function()
  1141. RotCamera(-RecoilX / 5, -RecoilY / 5, true, 0.1)
  1142. end)
  1143. if Idleing and (not Walking) and (not Aimed) then
  1144. local SpreadScale = (CurrentSpread / S.Spread.Max) * 50
  1145. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  1146. UDim2.new(0, 70 + 2 * SpreadScale, 0, 70 + 2 * SpreadScale),
  1147. UDim2.new(0, -35 - SpreadScale, 0, -35 - SpreadScale),
  1148. "Out", "Linear", 0.1, true
  1149. )
  1150. end
  1151.  
  1152. local KickSide = (
  1153. (
  1154. {
  1155. CurrentRecoil * (RAND(1, 5, 1) / 150);
  1156. CurrentRecoil * (RAND(1, 5, 1) / -150)
  1157. }
  1158. )[math.random(1, 2)]
  1159. ) * StanceSway
  1160. local KickBack = CurrentRecoil * StanceSway * 0.3
  1161. local KickUp = RAD(90 + (CurrentRecoil * RAND(1.3, 1.4, 0.01) * StanceSway))
  1162. TweenJoint(AnimWeld, CF(KickSide, 1, -KickBack), CFANG(KickUp - RAD(90), 0, 0), Linear, 1 / 12)
  1163.  
  1164. if FlashFX then FlashFX.Enabled = true end
  1165. if FlashGui then
  1166. FlashGui.Enabled = true
  1167. FlashGui.Label.Rotation = RAND(0, 360)
  1168. end
  1169.  
  1170. delay(1 / 30, function()
  1171. if Idleing and (not Walking) and (not Aimed) then
  1172. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  1173. UDim2.new(0, 70, 0, 70),
  1174. UDim2.new(0, -35, 0, -35),
  1175. "Out", "Linear", S.AimSpeed, (not Aimed)
  1176. )
  1177. end
  1178. if (not Aiming) and (not RunTween) then
  1179. TweenJoint(AnimWeld, CF(0, 1, 0), CF(), Linear, 0.15)
  1180. end
  1181. if FlashFX then FlashFX.Enabled = false end
  1182. if FlashGui then FlashGui.Enabled = false end
  1183. end)
  1184. end
  1185.  
  1186. function MarkHit()
  1187. spawn(function()
  1188. if Gui_Clone:IsDescendantOf(game) then
  1189. Gui_Clone.HitMarker.Visible = true
  1190. local StartMark = tick()
  1191. LastMark = StartMark
  1192. wait(0.5)
  1193. if LastMark <= StartMark then
  1194. Gui_Clone.HitMarker.Visible = false
  1195. end
  1196. end
  1197. end)
  1198. end
  1199.  
  1200. --------------------[ ADS FUNCTIONS ]-------------------------------------------------
  1201.  
  1202. function AimGun()
  1203. if (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude > 1 or Reloading or Knifing or ThrowingGrenade then return end
  1204. local Scope = Gui_Clone:WaitForChild("Scope"):WaitForChild("Img")
  1205. local Steady = Gui_Clone:WaitForChild("Scope"):WaitForChild("Steady")
  1206. Aimed = true
  1207. Aiming = true
  1208. CurrentRecoil = S.Recoil.Aimed
  1209. CurrentSpread = S.Spread.Aimed
  1210. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  1211. UDim2.new(),
  1212. UDim2.new(),
  1213. Enum.EasingDirection.Out,
  1214. Enum.EasingStyle.Sine,
  1215. S.AimAnimation and S.AimSpeed or 0,
  1216. true
  1217. )
  1218. if S.AimAnimation then
  1219. local CurrentFOV = Camera.FieldOfView
  1220. local CurrentCameraOffset = Humanoid.CameraOffset
  1221. local CurrentTrans = Scope.BackgroundTransparency
  1222. TweenJoint(LWeld, ArmC0[1], S.ArmC1_Aimed.Left, Sine, S.AimSpeed)
  1223. TweenJoint(RWeld, ArmC0[2], S.ArmC1_Aimed.Right, Sine, S.AimSpeed)
  1224. TweenJoint(AnimWeld, CF(0, 1, 0), CF(), Sine, S.AimSpeed)
  1225. TweenJoint(Grip, Grip.C0, Aimed_GripCF, Sine, S.AimSpeed)
  1226. TweenJoint(LWeld2, CF(), CF(), Sine, S.AimSpeed)
  1227. TweenJoint(RWeld2, CF(), CF(), Sine, S.AimSpeed)
  1228. local X = 0
  1229. while true do
  1230. local NewX = X + 1.5 / S.AimSpeed
  1231. X = (NewX > 90 and 90 or NewX)
  1232. if (not Aimed) then break end
  1233. if (not Selected) then break end
  1234. local Alpha = 1 - COS(RAD(X))
  1235. Camera.FieldOfView = NumLerp(CurrentFOV, S.MaxZoom, Alpha)
  1236. if S.GuiScope then
  1237. Scope.BackgroundTransparency = NumLerp(CurrentTrans, 0, Alpha)
  1238. end
  1239. if X == 90 then break end
  1240. RS:wait()
  1241. end
  1242. else
  1243. LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_Aimed.Left
  1244. RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_Aimed.Right
  1245. AnimWeld.C0 = CF(0, 1, 0)
  1246. Grip.C1 = Aimed_GripCF
  1247. LWeld2.C1, RWeld2.C1 = CF(), CF()
  1248. Camera.FieldOfView = S.MaxZoom
  1249. end
  1250. Aiming = (not Aimed)
  1251. if (not Aiming) and S.GuiScope then
  1252. spawn(function()
  1253. Steady.Visible = true
  1254. Scope.BackgroundTransparency = 1
  1255. Scope.ImageTransparency = 0
  1256.  
  1257. local Gun_Model = Instance.new("Model")
  1258. Gun_Model.Name = "Gun_Model"
  1259. for _, Obj in pairs(Gun:GetChildren()) do
  1260. if Obj:IsA("BasePart") then
  1261. local ObjClone = Obj:Clone()
  1262. ObjClone.Parent = Gun_Model
  1263.  
  1264. local W = Instance.new("Weld")
  1265. W.Part0 = ObjClone
  1266. W.Part1 = Obj
  1267. W.Parent = ObjClone
  1268.  
  1269. local PrevTrans = Instance.new("NumberValue")
  1270. PrevTrans.Name = "PrevTrans"
  1271. PrevTrans.Value = Obj.Transparency
  1272. PrevTrans.Parent = Obj
  1273.  
  1274. Obj.Transparency = 1
  1275. end
  1276. end
  1277. Gun_Model.Parent = Character
  1278. end)
  1279. spawn(function()
  1280. while Aimed do
  1281. local Ang = (CameraSteady and 0 or (Idleing and AnimAng[2] or AnimAng[4]))
  1282. if CameraSway ~= 0 then
  1283. local OffsetX, OffsetY = 0, 0
  1284. if Idleing then
  1285. OffsetX = (RAD(COS(Ang * 5 * (CameraSway ^ 0.4))) / 40) * (CameraSway ^ 1.2) * StanceSway * S.ScopeSway
  1286. OffsetY = (RAD(COS(Ang * 2 * (CameraSway ^ 0.4))) / 40) * (CameraSway ^ 1.2) * StanceSway * S.ScopeSway
  1287. else
  1288. OffsetX = (RAD(COS(Ang * 3/2 * (CameraSway ^ 0.4))) / 25) * (CameraSway ^ 1.2) * StanceSway * S.ScopeSway
  1289. OffsetY = (RAD(COS(Ang * 3/5 * (CameraSway ^ 0.4))) / 25) * (CameraSway ^ 1.2) * StanceSway * S.ScopeSway
  1290. end
  1291. RotCamera(OffsetX, OffsetY)
  1292. end
  1293. RS:wait()
  1294. end
  1295. end)
  1296. end
  1297. end
  1298.  
  1299. function UnAimGun(Exception)
  1300. local Scope = Gui_Clone:WaitForChild("Scope"):WaitForChild("Img")
  1301. local Steady = Gui_Clone:WaitForChild("Scope"):WaitForChild("Steady")
  1302. if (not Exception) then
  1303. if (not Aimed) then return end
  1304. if (Reloading and Exception) or Knifing and (not ThrowingGrenade) then return end
  1305. CurrentRecoil = S.Recoil.Hipfire
  1306. CurrentSpread = ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  1307. if Walking and Aimed then
  1308. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  1309. UDim2.new(0, 150, 0, 150),
  1310. UDim2.new(0, -75, 0, -75),
  1311. Enum.EasingDirection.Out,
  1312. Enum.EasingStyle.Linear,
  1313. S.AimAnimation and S.AimSpeed or 0,
  1314. true
  1315. )
  1316. elseif Idleing then
  1317. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  1318. UDim2.new(0, 70, 0, 70),
  1319. UDim2.new(0, -35, 0, -35),
  1320. Enum.EasingDirection.Out,
  1321. Enum.EasingStyle.Linear,
  1322. S.AimAnimation and S.AimSpeed or 0,
  1323. true
  1324. )
  1325. end
  1326. Aimed = false
  1327. Aiming = true
  1328. if S.GuiScope then
  1329. spawn(function()
  1330. local Gun_Model = Character:FindFirstChild("Gun_Model")
  1331. if Gun_Model then
  1332. Gun_Model:Destroy()
  1333. end
  1334.  
  1335. for _, Obj in pairs(Gun:GetChildren()) do
  1336. if Obj:IsA("BasePart") then
  1337. local PrevTrans = Obj:FindFirstChild("PrevTrans")
  1338.  
  1339. Obj.Transparency = PrevTrans.Value
  1340. PrevTrans:Destroy()
  1341. end
  1342. end
  1343. end)
  1344. end
  1345. if S.AimAnimation then
  1346. local CurrentFOV = Camera.FieldOfView
  1347. local CurrentCameraOffset = Humanoid.CameraOffset
  1348. local CurrentTrans = (Scope.BackgroundTransparency == 1 and (S.GuiScope and 0 or 1) or Scope.BackgroundTransparency)
  1349. Scope.ImageTransparency = 1
  1350. Steady.Visible = false
  1351. TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Sine, S.AimSpeed)
  1352. TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Sine, S.AimSpeed)
  1353. TweenJoint(Grip, Grip.C0, CFANG(0, RAD(20), 0), Sine, S.AimSpeed)
  1354. if S.PlayerAnimations then
  1355. TweenJoint(LWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, S.AimSpeed)
  1356. TweenJoint(RWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, S.AimSpeed)
  1357. end
  1358. local X = 0
  1359. while true do
  1360. local NewX = X + 1.5 / S.AimSpeed
  1361. X = (NewX > 90 and 90 or NewX)
  1362. if Aimed then break end
  1363. if (not Selected) then break end
  1364. local Alpha = 1 - COS(RAD(X))
  1365. Camera.FieldOfView = NumLerp(CurrentFOV, 70, Alpha)
  1366. Scope.BackgroundTransparency = NumLerp(CurrentTrans, 1, Alpha)
  1367. if X == 90 then break end
  1368. RS:wait()
  1369. end
  1370. else
  1371. Scope.BackgroundTransparency = 1
  1372. Scope.ImageTransparency = 1
  1373. Steady.Visible = false
  1374. LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_UnAimed.Left
  1375. RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_UnAimed.Right
  1376. Grip.C1 = CFANG(0, RAD(20), 0)
  1377. LWeld2.C1, RWeld2.C1 = CFANG(0, RAD(ArmTilt), 0), CFANG(0, RAD(ArmTilt), 0)
  1378. Camera.FieldOfView = 70
  1379. end
  1380. Aiming = Aimed
  1381. else
  1382. if S.GuiScope then
  1383. spawn(function()
  1384. local Gun_Model = Character:FindFirstChild("Gun_Model")
  1385. if Gun_Model then
  1386. Gun_Model:Destroy()
  1387. end
  1388.  
  1389. for _, Obj in pairs(Gun:GetChildren()) do
  1390. if Obj:IsA("BasePart") then
  1391. local PrevTrans = Obj:FindFirstChild("PrevTrans")
  1392.  
  1393. Obj.Transparency = PrevTrans.Value
  1394. PrevTrans:Destroy()
  1395. end
  1396. end
  1397. end)
  1398. end
  1399. spawn(function()
  1400. Aimed = false
  1401. Aiming = false
  1402. CurrentRecoil = S.Recoil.Hipfire
  1403. CurrentSpread = ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  1404. if (not Walking) then
  1405. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  1406. UDim2.new(0, 70, 0, 70),
  1407. UDim2.new(0, -35, 0, -35),
  1408. Enum.EasingDirection.Out,
  1409. Enum.EasingStyle.Linear,
  1410. S.AimAnimation and S.AimSpeed or 0,
  1411. true
  1412. )
  1413. else
  1414. Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
  1415. UDim2.new(0, 150, 0, 150),
  1416. UDim2.new(0, -75, 0, -75),
  1417. Enum.EasingDirection.Out,
  1418. Enum.EasingStyle.Linear,
  1419. S.AimAnimation and S.AimSpeed or 0,
  1420. true
  1421. )
  1422. end
  1423. local CurrentFOV = Camera.FieldOfView
  1424. local CurrentCameraOffset = Humanoid.CameraOffset
  1425. local CurrentTrans = (Scope.BackgroundTransparency == 1 and (S.GuiScope and 0 or 1) or Scope.BackgroundTransparency)
  1426. Scope.ImageTransparency = 1
  1427. Steady.Visible = false
  1428. if LWeld:FindFirstChild("TweenCode") then LWeld.TweenCode:Destroy() end
  1429. if RWeld:FindFirstChild("TweenCode") then RWeld.TweenCode:Destroy() end
  1430. if Grip:FindFirstChild("TweenCode") then Grip.TweenCode:Destroy() end
  1431. if LWeld2:FindFirstChild("TweenCode") then LWeld2.TweenCode:Destroy() end
  1432. if RWeld2:FindFirstChild("TweenCode") then RWeld2.TweenCode:Destroy() end
  1433. if S.AimAnimation then
  1434. local X = 0
  1435. while true do
  1436. local NewX = X + 1.5 / S.AimSpeed
  1437. X = (NewX > 90 and 90 or NewX)
  1438. if Aimed then break end
  1439. if (not Selected) then break end
  1440. local Alpha = 1 - COS(RAD(X))
  1441. Camera.FieldOfView = NumLerp(CurrentFOV, 70, Alpha)
  1442. Scope.BackgroundTransparency = NumLerp(CurrentTrans, 1, Alpha)
  1443. if X == 90 then break end
  1444. RS:wait()
  1445. end
  1446. else
  1447. Scope.BackgroundTransparency = 1
  1448. Scope.ImageTransparency = 1
  1449. Steady.Visible = false
  1450. Camera.FieldOfView = 70
  1451. end
  1452. end)
  1453. end
  1454. end
  1455.  
  1456. --------------------[ TEXTURE CREATION FUNCTIONS ]------------------------------------
  1457.  
  1458. function CreateBullet(Direction)
  1459. local Origin = Gun.Main.CFrame.p
  1460. local BulletMass = S.BulletSize.X * S.BulletSize.Y * S.BulletSize.Z
  1461. local BulletCF = CF(Origin, Origin + Direction)
  1462. local Bullet = Instance.new("Part")
  1463. Bullet.BrickColor = S.BulletColor
  1464. Bullet.Name = "Bullet"
  1465. Bullet.CanCollide = false
  1466. Bullet.FormFactor = "Custom"
  1467. Bullet.Size = S.BulletSize
  1468. Bullet.BottomSurface = "Smooth"
  1469. Bullet.TopSurface = "Smooth"
  1470. local Mesh = Instance.new("BlockMesh")
  1471. Mesh.Scale = S.BulletMeshSize
  1472. Mesh.Parent = Bullet
  1473. local BF = Instance.new("BodyForce")
  1474. BF.force = VEC3(0, BulletMass * (196.2 - S.BulletDropPerSecond), 0)
  1475. BF.Parent = Bullet
  1476. Bullet.Parent = Gun_Ignore
  1477. Bullet.CFrame = BulletCF + Direction * 3
  1478. Bullet.Velocity = Direction * S.BulletVelocity
  1479. return Bullet
  1480. end
  1481.  
  1482. function CreateBulletHole(HitPos, HitObj)
  1483. local SurfaceCF = GetHitSurfaceCFrame(HitPos, HitObj)
  1484. local SurfaceDir = CF(HitObj.CFrame.p, SurfaceCF.p)
  1485. local SurfaceDist = SurfaceDir.lookVector * (HitObj.CFrame.p - SurfaceCF.p).magnitude / 2
  1486. local SurfaceOffset = HitPos - SurfaceCF.p + SurfaceDist
  1487. local SurfaceCFrame = SurfaceDir + SurfaceDist + SurfaceOffset
  1488. local HitMark = Instance.new("Part")
  1489. HitMark.BrickColor = BrickColor.new("Black")
  1490. HitMark.Transparency = 1
  1491. HitMark.Anchored = true
  1492. HitMark.CanCollide = false
  1493. HitMark.FormFactor = "Custom"
  1494. HitMark.Size = VEC3(1, 1, 0.2)
  1495. HitMark.TopSurface = 0
  1496. HitMark.BottomSurface = 0
  1497. local Mesh = Instance.new("BlockMesh")
  1498. Mesh.Offset = VEC3(0, 0, -0.05)
  1499. Mesh.Scale = VEC3(S.BulletHoleSize, S.BulletHoleSize, 0)
  1500. Mesh.Parent = HitMark
  1501. local Decal = Instance.new("Decal")
  1502. Decal.Face = Enum.NormalId.Front
  1503. Decal.Texture = S.BulletHoleTexture
  1504. Decal.Parent = HitMark
  1505. HitMark.Parent = Gun_Ignore
  1506. HitMark.CFrame = SurfaceCFrame
  1507. if (not HitObj.Anchored) then
  1508. local Weld = Instance.new("Weld", HitMark)
  1509. Weld.Part0 = HitObj
  1510. Weld.Part1 = HitMark
  1511. Weld.C0 = HitObj.CFrame:toObjectSpace(SurfaceCFrame)
  1512. HitMark.Anchored = false
  1513. end
  1514. delay(S.BulletHoleVisibleTime, function()
  1515. if S.BulletHoleDisappearTime > 0 then
  1516. local X = 0
  1517. while true do
  1518. if X == 90 then break end
  1519. if (not Selected) then break end
  1520. local NewX = X + (1.5 / S.BulletHoleDisappearTime)
  1521. X = (NewX > 90 and 90 or NewX)
  1522. local Alpha = X / 90
  1523. Decal.Transparency = NumLerp(0, 1, Alpha)
  1524. RS:wait()
  1525. end
  1526. HitMark:Destroy()
  1527. else
  1528. HitMark:Destroy()
  1529. end
  1530. end)
  1531. end
  1532.  
  1533. function CreateShockwave(Center, Radius)
  1534. local Shockwave = Instance.new("Part")
  1535. Shockwave.BrickColor = S.ShockwaveColor
  1536. Shockwave.Material = Enum.Material.SmoothPlastic
  1537. Shockwave.Name = "Shockwave"
  1538. Shockwave.Anchored = true
  1539. Shockwave.CanCollide = false
  1540. Shockwave.FormFactor = Enum.FormFactor.Symmetric
  1541. Shockwave.Size = VEC3(1, 1, 1)
  1542. Shockwave.BottomSurface = Enum.SurfaceType.Smooth
  1543. Shockwave.TopSurface = Enum.SurfaceType.Smooth
  1544. local Mesh = Instance.new("SpecialMesh")
  1545. Mesh.MeshType = Enum.MeshType.Sphere
  1546. Mesh.Scale = VEC3()
  1547. Mesh.Parent = Shockwave
  1548. Shockwave.Parent = Gun_Ignore
  1549. Shockwave.CFrame = CF(Center)
  1550. spawn(function()
  1551. for i = 0, 1, (1 / (60 * S.ShockwaveDuration)) do
  1552. local Scale = 2 * Radius * i
  1553. Mesh.Scale = VEC3(Scale, Scale, Scale)
  1554. Shockwave.Transparency = i
  1555. RS:wait()
  1556. end
  1557. Shockwave:Destroy()
  1558. end)
  1559. end
  1560.  
  1561. --------------------[ HIT HANDLING FUNCTIONS ]----------------------------------------
  1562.  
  1563. function Damage(HitObj, HitPos)
  1564. local HeadVal = S.Multipliers.Head
  1565. local ChestVal = S.Multipliers.Chest
  1566. local LimbsVal = S.Multipliers.Limbs
  1567. if Humanoid.Health ~= 0 then
  1568. if HitObj and HitObj.Parent then
  1569. local HumanoidFound = false
  1570. local HitHumanoid = nil
  1571. if HitObj.Parent.ClassName == "Hat" then
  1572. if FindFirstClass(HitObj.Parent.Parent, "Humanoid") then
  1573. HitHumanoid = FindFirstClass(HitObj.Parent.Parent, "Humanoid")
  1574. HumanoidFound = true
  1575. if HitHumanoid.Health > 0 then
  1576. if IsEnemy(HitHumanoid) then
  1577. local CreatorTag = Instance.new("ObjectValue")
  1578. CreatorTag.Value = Player
  1579. CreatorTag.Name = "creator"
  1580. CreatorTag.Parent = HitHumanoid
  1581. HitHumanoid:TakeDamage(S.Damage * RAND(HeadVal, HeadVal + 0.1, 0.01))
  1582. MarkHit()
  1583. end
  1584. end
  1585. end
  1586. else
  1587. if FindFirstClass(HitObj.Parent, "Humanoid") then
  1588. HitHumanoid = FindFirstClass(HitObj.Parent, "Humanoid")
  1589. HumanoidFound = true
  1590. if HitHumanoid.Health > 0 then
  1591. if IsEnemy(HitHumanoid) then
  1592. local CreatorTag = Instance.new("ObjectValue")
  1593. CreatorTag.Value = Player
  1594. CreatorTag.Name = "creator"
  1595. CreatorTag.Parent = HitHumanoid
  1596. local ChosenDamage = 0
  1597. if HitObj.Name == "Head" then
  1598. ChosenDamage = S.Damage * RAND(HeadVal, HeadVal + 0.1, 0.01)
  1599. elseif HitObj.Name == "Torso" then
  1600. ChosenDamage = S.Damage * RAND(ChestVal, ChestVal + 0.1, 0.01)
  1601. else
  1602. ChosenDamage = S.Damage * RAND(LimbsVal, LimbsVal + 0.1, 0.01)
  1603. end
  1604. HitHumanoid:TakeDamage(ChosenDamage)
  1605. MarkHit()
  1606. end
  1607. end
  1608. end
  1609. end
  1610. if (not HumanoidFound) then
  1611. if S.BulletHoles then
  1612. CreateBulletHole(HitPos, HitObj)
  1613. end
  1614. if S.Shockwaves then
  1615. CreateShockwave(HitPos, S.ShockwaveRadius)
  1616. end
  1617. end
  1618. return HitHumanoid
  1619. end
  1620. end
  1621. end
  1622.  
  1623. function PenetrateWall(HitPos, Direction, HitHumanoid, OriginPos, Bullet)
  1624. local HitDist = (HitPos - OriginPos).magnitude
  1625. local Thickness, Wall, WallHitPos = 0, nil, nil
  1626. for i = 0.1, S.Penetration, 0.1 do
  1627. local WallRay = Ray.new(HitPos + (Direction * i), -Direction)
  1628. local TempWall, TempWallHitPos = game.Workspace:FindPartOnRayWithIgnoreList(WallRay, Ignore)
  1629. if TempWall then
  1630. Thickness = i
  1631. Wall, WallHitPos = TempWall, TempWallHitPos
  1632. break
  1633. end
  1634. end
  1635. if Wall then
  1636. CreateBulletHole(WallHitPos, Wall)
  1637. if S.InstantHit then
  1638. local HitObj2, HitPos2 = nil, nil
  1639. if HitHumanoid then
  1640. HitObj2, HitPos2 = AdvRayCast(WallHitPos, Direction, S.BulletRange - HitDist, {HitHumanoid.Parent,unpack(Ignore)})
  1641. else
  1642. HitObj2, HitPos2 = AdvRayCast(WallHitPos, Direction, S.BulletRange - HitDist)
  1643. end
  1644. Damage(HitObj2, HitPos2)
  1645. return HitPos2
  1646. else
  1647. local LastPos = WallHitPos
  1648. local TotalDistTraveled = 0
  1649. spawn(function()
  1650. while true do
  1651. RS:wait()
  1652. if TotalDistTraveled >= S.BulletRange - HitDist then
  1653. Bullet:Destroy()
  1654. break
  1655. end
  1656. local DistTraveled = (Bullet.Position - LastPos).magnitude
  1657. local NewDirection = (Bullet.Position - LastPos).unit
  1658. local TempHitObj, TempHitPos = nil, nil
  1659. if HitHumanoid then
  1660. TempHitObj, TempHitPos = AdvRayCast(LastPos, NewDirection, DistTraveled, {HitHumanoid.Parent,unpack(Ignore)})
  1661. else
  1662. TempHitObj, TempHitPos = AdvRayCast(LastPos, NewDirection, DistTraveled)
  1663. end
  1664. if TempHitObj then
  1665. Damage(TempHitObj, TempHitPos)
  1666. Bullet:Destroy()
  1667. return TempHitPos
  1668. else
  1669. LastPos = Bullet.Position
  1670. TotalDistTraveled = TotalDistTraveled + DistTraveled
  1671. end
  1672. end
  1673. end)
  1674. end
  1675. else
  1676. if Bullet then Bullet:Destroy() end
  1677. return HitPos
  1678. end
  1679. end
  1680.  
  1681. function IsEnemy(Human)
  1682. local Plyr = game.Players:GetPlayerFromCharacter(Human.Parent)
  1683. if (not Plyr) then return S.CanDamageNPCs end
  1684. return S.AllowFriendlyFire or (Plyr.TeamColor ~= Player.TeamColor or Plyr.Neutral)
  1685. end
  1686.  
  1687. --------------------[ RELOAD FUNCTIONS ]----------------------------------------------
  1688.  
  1689. function ReloadAnim()
  1690. TweenJoint(LWeld2, CF(), CF(), Sine, 0.15)
  1691. TweenJoint(RWeld2, CF(), CF(), Sine, 0.15)
  1692. local Speed = S.ReloadTime / 2
  1693. local Mag_Parts = {}
  1694.  
  1695. for _, Obj in pairs(Gun:GetChildren()) do
  1696. if Obj.Name == "Mag" and Obj:IsA("BasePart") then
  1697. INSERT(Mag_Parts, {Original = Obj, Clone1 = Obj:Clone(), Clone2 = Obj:Clone()})
  1698. end
  1699. end
  1700.  
  1701. local W1 = nil
  1702. local W2 = nil
  1703.  
  1704. local SequenceTable = {
  1705.  
  1706. function()
  1707.  
  1708. for Index, Mag in pairs(Mag_Parts) do
  1709. Mag.Original.Transparency = 1
  1710. Mag.Clone1.Parent = Gun_Ignore
  1711. Mag.Clone1.CanCollide = true
  1712.  
  1713. if Index ~= 1 then
  1714. local W = Instance.new("Weld")
  1715. W.Part0 = Mag_Parts[1].Clone1
  1716. W.Part1 = Mag.Clone1
  1717. W.C0 = Mag_Parts[1].Clone1.CFrame:toObjectSpace(Mag.Clone1.CFrame)
  1718. W.Parent = Mag_Parts[1].Clone1
  1719. end
  1720. end
  1721.  
  1722. W1 = Instance.new("Weld")
  1723. W1.Part0 = Mag_Parts[1].Clone1
  1724. W1.Part1 = Handle
  1725. W1.C0 = Mag_Parts[1].Original.CFrame:toObjectSpace(Handle.CFrame)
  1726. W1.Parent = Mag_Parts[1].Clone1
  1727.  
  1728. TweenJoint(LWeld, ArmC0[1], CF(0, 0.61, 0) * CFANG(RAD(70), 0, 0), Linear, 0.5 * Speed)
  1729. TweenJoint(RWeld, ArmC0[2], CF(0.4, 0.09, -0.21) * CFANG(RAD(-20), RAD(3), 0), Linear, 0.5 * Speed)
  1730. TweenJoint(Grip, Grip.C0, CFANG(0, RAD(10), 0), Linear, 0.5 * Speed)
  1731. wait(0.5 * Speed)
  1732.  
  1733. end;
  1734.  
  1735. function()
  1736.  
  1737. TweenJoint(RWeld, ArmC0[2], CF(0.4, -0.01, -0.31) * CFANG(RAD(-22), RAD(3), 0), Sine, 0.3 * Speed)
  1738. wait(0.2 * Speed)
  1739.  
  1740. end;
  1741.  
  1742. function()
  1743.  
  1744. W1:Destroy()
  1745. Mag_Parts[1].Clone1.Velocity = Handle.Velocity + Handle.CFrame:vectorToWorldSpace(VEC3(0,-1,0)) * 20
  1746. spawn(function()
  1747. while Mag_Parts[1].Clone1.Velocity.magnitude > 0.1 do wait() end
  1748. for _, Mag in pairs(Mag_Parts) do
  1749. Mag.Clone1.Anchored = true
  1750. Mag.Clone1:BreakJoints()
  1751. end
  1752. end)
  1753.  
  1754. for Index, Mag in pairs(Mag_Parts) do
  1755. Mag.Clone2.Parent = Gun_Ignore
  1756.  
  1757. if Index ~= 1 then
  1758. local W = Instance.new("Weld")
  1759. W.Part0 = Mag_Parts[1].Clone2
  1760. W.Part1 = Mag.Clone2
  1761. W.C0 = Mag_Parts[1].Clone2.CFrame:toObjectSpace(Mag.Clone2.CFrame)
  1762. W.Parent = Mag_Parts[1].Clone2
  1763. end
  1764. end
  1765.  
  1766. W2 = Instance.new("Weld")
  1767. W2.Part0 = FakeLArm
  1768. W2.Part1 = Mag_Parts[1].Clone2
  1769. W2.C0 = CF(0, -1, 0) * CFANG(RAD(-90), 0, 0)
  1770. W2.Parent = FakeLArm
  1771. wait(0.1)
  1772.  
  1773. end;
  1774.  
  1775. function()
  1776.  
  1777. local FakeLArmCF = LWeld.Part0.CFrame * ArmC0[1] * (CF(0.3, 1.85, -0.31) * CFANG(RAD(-20), RAD(30), RAD(-60))):inverse()
  1778. local FakeRArmCF = RWeld.Part0.CFrame * ArmC0[2] * (CF(0.4, -0.1, -0.21) * CFANG(RAD(-20), RAD(5), RAD(10))):inverse()
  1779. local HandleCF = FakeRArm.CFrame:toObjectSpace(Grip.Part0.CFrame * Grip.C0)
  1780. local Mag_Original_CF = Handle.CFrame:toObjectSpace(Mag_Parts[1].Original.CFrame)
  1781. local MagC0 = FakeLArmCF:toObjectSpace(FakeRArmCF * HandleCF * Mag_Original_CF)
  1782.  
  1783. TweenJoint(LWeld, ArmC0[1], CF(0.3, 1.85, -0.31) * CFANG(RAD(-20), RAD(30), RAD(-60)), Sine, 0.6 * Speed)
  1784. TweenJoint(RWeld, ArmC0[2], CF(0.4, -0.1, -0.21) * CFANG(RAD(-20), RAD(5), RAD(10)), Sine, 0.6 * Speed)
  1785. TweenJoint(Grip, Grip.C0, CF(), Sine, 0.6 * Speed)
  1786. TweenJoint(W2, MagC0, CF(), Sine, 0.6 * Speed)
  1787. wait(0.7 * Speed)
  1788.  
  1789. end;
  1790.  
  1791. function()
  1792.  
  1793. for _, Mag in pairs(Mag_Parts) do
  1794. Mag.Original.Transparency = 0
  1795. Mag.Clone2:Destroy()
  1796. end
  1797.  
  1798. TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Sine, 0.5 * Speed)
  1799. TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Sine, 0.5 * Speed)
  1800. TweenJoint(Grip, Grip.C0, CFANG(0, RAD(20), 0), Sine, 0.5 * Speed)
  1801. wait(0.5 * Speed)
  1802.  
  1803. end;
  1804.  
  1805. }
  1806.  
  1807. for _,ReloadFunction in pairs(SequenceTable) do
  1808. if BreakReload then
  1809. break
  1810. end
  1811. ReloadFunction()
  1812. end
  1813.  
  1814. if W1 then W1:Destroy() end
  1815. if W2 then W2:Destroy() end
  1816. for _, Mag in pairs(Mag_Parts) do
  1817. Mag.Clone1:Destroy()
  1818. Mag.Clone2:Destroy()
  1819. end
  1820. end
  1821.  
  1822. function Reload()
  1823. Running = false
  1824. if Ammo.Value < ClipSize.Value and (not Reloading) and StoredAmmo.Value > 0 then
  1825. AmmoInClip = (AmmoInClip == 0 and Ammo.Value or AmmoInClip)
  1826. Ammo.Value = 0
  1827. Reloading = true
  1828. if Aimed then UnAimGun(S.ReloadAnimation) end
  1829. Gui_Clone.CrossHair.Reload.Visible = true
  1830. if Handle:FindFirstChild("ReloadSound") then Handle.ReloadSound:Play() end
  1831. if S.ReloadAnimation then
  1832. wait()
  1833. ReloadAnim()
  1834. else
  1835. local StartReload = tick()
  1836. while true do
  1837. if BreakReload then break end
  1838. if (tick() - StartReload) >= S.ReloadTime then break end
  1839. RS:wait()
  1840. end
  1841. end
  1842. if (not BreakReload) then
  1843. if StoredAmmo.Value >= ClipSize.Value then
  1844. Ammo.Value = ClipSize.Value
  1845. if AmmoInClip > 0 then
  1846. StoredAmmo.Value = StoredAmmo.Value - (ClipSize.Value - AmmoInClip)
  1847. else
  1848. StoredAmmo.Value = StoredAmmo.Value - ClipSize.Value
  1849. end
  1850. elseif StoredAmmo.Value < ClipSize.Value and StoredAmmo.Value > 0 then
  1851. Ammo.Value = StoredAmmo.Value
  1852. StoredAmmo.Value = 0
  1853. end
  1854. end
  1855. BreakReload = false
  1856. Reloading = false
  1857. if Selected then
  1858. AmmoInClip = 0
  1859. Gui_Clone.CrossHair.Reload.Visible = false
  1860. end
  1861. end
  1862. end
  1863.  
  1864. --------------------[ EXTERNAL DATA LOCATING FUNCTIONS ]-----------------------------
  1865.  
  1866. function FindFirstClass(Object, Class)
  1867. local FoundObject = nil
  1868. for _, Obj in pairs(Object:GetChildren()) do
  1869. if Obj.ClassName == Class then
  1870. FoundObject = Obj
  1871. break
  1872. end
  1873. end
  1874. return FoundObject
  1875. end
  1876.  
  1877. function IsIgnored(Obj)
  1878. for _,v in pairs(Ignore) do
  1879. if Obj == v or Obj:IsDescendantOf(v) then
  1880. return true
  1881. end
  1882. end
  1883. return false
  1884. end
  1885.  
  1886. function GetHitSurfaceCFrame(HitPos,Obj)
  1887. local SurfaceCF = {
  1888. {"Back",Obj.CFrame * CF(0,0,Obj.Size.z)};
  1889. {"Bottom",Obj.CFrame * CF(0,-Obj.Size.y,0)};
  1890. {"Front",Obj.CFrame * CF(0,0,-Obj.Size.z)};
  1891. {"Left",Obj.CFrame * CF(-Obj.Size.x,0,0)};
  1892. {"Right",Obj.CFrame * CF(Obj.Size.x,0,0)};
  1893. {"Top",Obj.CFrame * CF(0,Obj.Size.y,0)}
  1894. }
  1895. local ClosestDist = HUGE
  1896. local ClosestSurface = nil
  1897. for _,v in pairs(SurfaceCF) do
  1898. local SurfaceDist = (HitPos - v[2].p).magnitude
  1899. if SurfaceDist < ClosestDist then
  1900. ClosestDist = SurfaceDist
  1901. ClosestSurface = v
  1902. end
  1903. end
  1904. return ClosestSurface[2]
  1905. end
  1906.  
  1907. function AdvRayCast(Origin, Direction, Dist, CustomIgnore)
  1908. local NewIgnore = (CustomIgnore and CustomIgnore or Ignore)
  1909. local NewRay = Ray.new(Origin, Direction * (Dist > 999 and 999 or Dist))
  1910. local HitObj, HitPos = game.Workspace:FindPartOnRayWithIgnoreList(NewRay, NewIgnore)
  1911. local LastPos = HitPos
  1912. local FinalHitObj, FinalHitPos = nil, nil
  1913. local RepTimes = math.floor(Dist / 999)
  1914. if (not HitObj) and (Dist > 999) then
  1915. for i = 0, RepTimes do
  1916. local NewDist = (i == RepTimes and (Dist - (LastPos - Origin).magnitude) or 999)
  1917. local Ray2 = Ray.new(LastPos, Direction * NewDist)
  1918. local HitObj2, HitPos2 = game.Workspace:FindPartOnRayWithIgnoreList(Ray2, NewIgnore)
  1919. if i ~= RepTimes then
  1920. if HitObj2 then
  1921. FinalHitObj, FinalHitPos = HitObj2, HitPos2
  1922. break
  1923. end
  1924. elseif i == RepTimes then
  1925. FinalHitObj, FinalHitPos = HitObj2, HitPos2
  1926. end
  1927. LastPos = HitPos2
  1928. end
  1929. return FinalHitObj, FinalHitPos
  1930. elseif HitObj or (Dist <= 999) then
  1931. return HitObj, HitPos
  1932. end
  1933. end
  1934.  
  1935. --------------------[ KNIFING FUNCTION ]----------------------------------------------
  1936.  
  1937. function KnifeAnim()
  1938. local Connection = nil
  1939. local Blade = Instance.new("Part")
  1940. Blade.BrickColor = BrickColor.new("Really black")
  1941. Blade.Name = "Blade"
  1942. Blade.CanCollide = false
  1943. Blade.FormFactor = Enum.FormFactor.Custom
  1944. Blade.Size = VEC3(0.5, 2.5, 1)
  1945. local Mesh = Instance.new("SpecialMesh")
  1946. Mesh.MeshId = S.KnifeMeshId
  1947. Mesh.MeshType = Enum.MeshType.FileMesh
  1948. Mesh.Scale = VEC3(0.7, 0.7, 0.7)
  1949. Mesh.TextureId = S.KnifeTextureId
  1950. Mesh.Parent = Blade
  1951. Blade.Parent = Gun_Ignore
  1952. local BladeWeld = Instance.new("Weld")
  1953. BladeWeld.Part0 = Blade
  1954. BladeWeld.Part1 = FakeLArm
  1955. BladeWeld.C0 = CFANG(RAD(-90), 0, RAD(180))
  1956. BladeWeld.C1 = CF(0, -1, 0.75)
  1957. BladeWeld.Parent = Blade
  1958. Connection = Blade.Touched:connect(function(Obj)
  1959. if Obj then
  1960. local HitHumanoid = FindFirstClass(Obj.Parent, "Humanoid")
  1961. if HitHumanoid and IsEnemy(HitHumanoid) then
  1962. local CreatorTag = Instance.new("ObjectValue")
  1963. CreatorTag.Name = "creator"
  1964. CreatorTag.Value = Player
  1965. CreatorTag.Parent = HitHumanoid
  1966. HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
  1967. MarkHit()
  1968. end
  1969. end
  1970. end)
  1971. TweenJoint(LWeld2, CF(), CFANG(0, RAD(90), 0), Linear, 0.05)
  1972. TweenJoint(LWeld, ArmC0[1], CF(-0.1, 0.2, -0.1) * CFANG(0, 0, RAD(-20)), Linear, 0.05)
  1973. TweenJoint(RWeld, ArmC0[2], CFANG(RAD(-30), 0, 0), Linear, 0.1)
  1974. TweenJoint(Grip, Grip.C0, CF(), Linear, 0.1)
  1975. spawn(function()
  1976. local Force = HRP.CFrame.lookVector * 8e4
  1977. local BF = Instance.new("BodyForce")
  1978. BF.force = Force
  1979. BF.Parent = HRP
  1980. delay(0.03, function()
  1981. BF.force = -Force / 2
  1982. wait(0.03)
  1983. BF:Destroy()
  1984. end)
  1985. end)
  1986. wait(0.05)
  1987. RotCamera(RAD(6), 0, true, 0.1)
  1988. delay(0.1, function()
  1989. RotCamera(RAD(-2), 0, true, 0.05)
  1990. end)
  1991. TweenJoint(LWeld, ArmC0[1], CF(0.8, 1.7, 0.2) * CFANG(0, 0, RAD(-80)), Linear, 0.06)
  1992. wait(0.2)
  1993. Connection:disconnect()
  1994. wait(0.2)
  1995. TweenJoint(LWeld2, CF(), CF(), Linear, 0.15)
  1996. TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Linear, 0.15)
  1997. TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Linear, 0.15)
  1998. Blade:Destroy()
  1999. end
  2000.  
  2001. --------------------[ GRENADE FUNCTIONS ]---------------------------------------------
  2002.  
  2003. function CreateGrenade()
  2004. local Grenade = Instance.new("Model")
  2005.  
  2006. local Center = Instance.new("Part")
  2007. Center.BrickColor = S.GrenadeColor
  2008. Center.Name = "Center"
  2009. Center.CanCollide = false
  2010. Center.Elasticity = 0
  2011. Center.FormFactor = Enum.FormFactor.Custom
  2012. Center.Size = S.GrenadeSize
  2013. Center.BottomSurface = Enum.SurfaceType.Smooth
  2014. Center.TopSurface = Enum.SurfaceType.Smooth
  2015. Center.Parent = Grenade
  2016.  
  2017. local Mesh1 = Instance.new("SpecialMesh")
  2018. Mesh1.MeshType = Enum.MeshType.Sphere
  2019. Mesh1.Parent = Center
  2020.  
  2021. return Grenade
  2022. end
  2023.  
  2024. function CreateKnife()
  2025. local Knife = Instance.new("Part")
  2026. Knife.BrickColor = S.GrenadeColor
  2027. Knife.Name = "Knife"
  2028. Knife.CanCollide = false
  2029. Knife.FormFactor = Enum.FormFactor.Custom
  2030. Knife.Size = VEC3(1, 1, 3)
  2031.  
  2032. local Mesh = Instance.new("SpecialMesh")
  2033. Mesh.MeshId = "http://www.roblox.com/asset/?id=12221720"
  2034. Mesh.MeshType = Enum.MeshType.FileMesh
  2035. Mesh.Scale = VEC3(0.5, 0.5, 0.5)
  2036. Mesh.Parent = Knife
  2037.  
  2038. return Knife
  2039. end
  2040.  
  2041. function CreateTarget()
  2042. local Target = Instance.new("Model")
  2043.  
  2044. local Center = Instance.new("Part")
  2045. Center.BrickColor = BrickColor.new("Bright red")
  2046. Center.Material = Enum.Material.SmoothPlastic
  2047. Center.Transparency = 0.3
  2048. Center.Name = "Center"
  2049. Center.Anchored = true
  2050. Center.CanCollide = false
  2051. Center.FormFactor = Enum.FormFactor.Custom
  2052. Center.Size = VEC3(4, 0.2, 4)
  2053. Center.Parent = Target
  2054. local CylinderMesh = Instance.new("CylinderMesh")
  2055. CylinderMesh.Parent = Center
  2056.  
  2057. local Line = Instance.new("Part")
  2058. Line.BrickColor = BrickColor.new("Bright red")
  2059. Line.Transparency = 0.3
  2060. Line.Name = "Line"
  2061. Line.CFrame = Center.CFrame * CFrame.new(0, 5.1, 0)
  2062. Line.Anchored = true
  2063. Line.CanCollide = false
  2064. Line.FormFactor = Enum.FormFactor.Custom
  2065. Line.Size = VEC3(0.4, 10, 0.4)
  2066. Line.BottomSurface = Enum.SurfaceType.Smooth
  2067. Line.TopSurface = Enum.SurfaceType.Smooth
  2068. Line.Parent = Target
  2069.  
  2070. return Target
  2071. end
  2072.  
  2073. function DetonateExplosive(Grenade)
  2074. CreateShockwave(Grenade.Position, S.GrenadeBlastRadius)
  2075. local GrenadePos = Grenade.Position
  2076. local E = Instance.new("Explosion")
  2077. E.BlastPressure = S.GrenadeBlastPressure
  2078. E.BlastRadius = S.GrenadeBlastRadius
  2079. E.DestroyJointRadiusPercent = (S.GrenadeRangeBasedDamage and 0 or 1)
  2080. E.ExplosionType = S.GrenadeExplosionType
  2081. E.Position = GrenadePos
  2082. E.Hit:connect(function(HObj, HDist)
  2083. if HObj.Name == "Torso" and (not HObj:IsDescendantOf(Character)) then
  2084. if S.GrenadeRangeBasedDamage then
  2085. local ClosestPart = nil
  2086. local ClosestDist = math.huge
  2087.  
  2088. for _, P in pairs(HObj.Parent:GetChildren()) do
  2089. if P:IsA("BasePart") then
  2090. local Dist = (GrenadePos - P.Position).magnitude
  2091. if Dist < ClosestDist then
  2092. ClosestPart = P
  2093. ClosestDist = Dist
  2094. end
  2095. end
  2096. end
  2097.  
  2098. local Dir = (ClosestPart.Position - GrenadePos).unit
  2099. local H, P = AdvRayCast(GrenadePos, Dir, 999)
  2100. local RayHitHuman = H:IsDescendantOf(HObj.Parent)
  2101. if (S.GrenadeRayCastExplosions and RayHitHuman) or (not S.GrenadeRayCastExplosions) then
  2102. local HitHumanoid = FindFirstClass(HObj.Parent, "Humanoid")
  2103. if HitHumanoid and HitHumanoid.Health > 0 and IsEnemy(HitHumanoid) then
  2104. local DistFactor = ClosestDist / S.GrenadeBlastRadius
  2105. local DistInvert = math.max(1 - DistFactor,0)
  2106. local NewDamage = DistInvert * S.LethalGrenadeDamage
  2107.  
  2108. local CreatorTag = Instance.new("ObjectValue")
  2109. CreatorTag.Value = Player
  2110. CreatorTag.Name = "creator"
  2111. CreatorTag.Parent = HitHumanoid
  2112. HitHumanoid:TakeDamage(NewDamage)
  2113. MarkHit()
  2114. end
  2115. end
  2116. else
  2117. local HitHumanoid = FindFirstClass(HObj.Parent, "Humanoid")
  2118. if HitHumanoid and HitHumanoid.Health > 0 and IsEnemy(HitHumanoid) then
  2119. local CreatorTag = Instance.new("ObjectValue")
  2120. CreatorTag.Value = Player
  2121. CreatorTag.Name = "creator"
  2122. CreatorTag.Parent = HitHumanoid
  2123. MarkHit()
  2124. end
  2125. end
  2126. end
  2127. end)
  2128. E.Parent = game.Workspace
  2129.  
  2130. wait()
  2131.  
  2132. Grenade.Parent:Destroy()
  2133. end
  2134.  
  2135. function DetonateSmoke(Grenade)
  2136. CreateShockwave(Grenade.Position, S.GrenadeEffectRadius)
  2137. local GrenadePos = Grenade.Position
  2138.  
  2139. spawn(function()
  2140. for i = 1, math.floor(S.GrenadeEffectRadius / 5) + RAND(5, 10) do
  2141. local Size = RAND(S.GrenadeEffectRadius * 0.6, S.GrenadeEffectRadius * 0.8)
  2142. local Dist = RAND(0, S.GrenadeEffectRadius - Size)
  2143. local XRot, YRot = RAD(RAND(0, 180, 10)), RAD(RAND(0, 360, 10))
  2144. local RotLV = (CFANG(0, YRot, 0) * CFANG(XRot, 0, 0)).lookVector
  2145. local Pos = GrenadePos + (RotLV * VEC3(Dist, Dist / 2, Dist))
  2146.  
  2147. local Smoke = Instance.new("Part")
  2148. Smoke.Transparency = 1
  2149. Smoke.Name = "Smoke"
  2150. Smoke.Anchored = true
  2151. Smoke.CanCollide = false
  2152. Smoke.FormFactor = Enum.FormFactor.Symmetric
  2153. Smoke.Size = VEC3(1, 1, 1)
  2154. Smoke.TopSurface = Enum.SurfaceType.Smooth
  2155. Smoke.BottomSurface = Enum.SurfaceType.Smooth
  2156.  
  2157. local Mesh = Instance.new("SpecialMesh")
  2158. Mesh.MeshType = Enum.MeshType.Sphere
  2159. Mesh.Scale = VEC3(Size, Size, Size)
  2160. Mesh.Parent = Smoke
  2161.  
  2162. Smoke.Parent = Gun_Ignore
  2163. Smoke.CFrame = CF(Pos)
  2164.  
  2165. spawn(function()
  2166. local Trans = RAND(0.3, 0.5, 0.01)
  2167. for X = 0, 90, 2 do
  2168. Smoke.CFrame = CF(GrenadePos:lerp(Pos, Sine(X)))
  2169. Smoke.Transparency = NumLerp(1, Trans, Sine(X))
  2170. RS:wait()
  2171. end
  2172.  
  2173. wait(S.GrenadeEffectTime)
  2174.  
  2175. for X = 0, 90, 0.5 do
  2176. Smoke.CFrame = CF(Pos:lerp(Pos + VEC3(0, 20, 0), 1 - COS(RAD(X))))
  2177. Smoke.Transparency = NumLerp(Trans, 1, Sine(X))
  2178. RS:wait()
  2179. end
  2180.  
  2181. Smoke:Destroy()
  2182. end)
  2183.  
  2184. if i % 3 == 0 then
  2185. RS:wait()
  2186. end
  2187. end
  2188. end)
  2189.  
  2190. wait()
  2191.  
  2192. Grenade.Parent:Destroy()
  2193. end
  2194.  
  2195. function ThrowGrenade(Type)
  2196. local Grenade0 = nil
  2197. if S.TrajectoryAssist then
  2198. spawn(function()
  2199. local X = 0
  2200. local Vel = (Type == 1 and S.LethalGrenadeThrowVelocity or S.TacticalGrenadeThrowVelocity)
  2201.  
  2202. local GetX = function(Ang, T)
  2203. local Vx = Vel * math.cos(Ang)
  2204. return Vx * T
  2205. end
  2206.  
  2207. local GetY = function(Ang, T)
  2208. local V0y = Vel * math.sin(Ang)
  2209. local Vy = V0y + (-196.2 * T)
  2210. return (Vy * T) - (-98.1 * T * T)
  2211. end
  2212.  
  2213. local Target = CreateTarget()
  2214. Target.Parent = game.Workspace
  2215. Target.PrimaryPart = Target:WaitForChild("Center")
  2216.  
  2217. while (Keys[S.LethalGrenadeKey] or Keys[S.TacticalGrenadeKey]) and Selected do
  2218. X = X + math.rad(10)
  2219. for _,v in pairs(Target:GetChildren()) do
  2220. v.Transparency = 0.2 + ((math.sin(X) + 1) / 5)
  2221. end
  2222.  
  2223. local Lines = {}
  2224. local LastX, LastY = nil, nil
  2225. for T = 0, 10, 0.1 do
  2226. local XPos = GetX(math.rad(7) - HeadRot, T)
  2227. local YPos = GetY(math.rad(7) - HeadRot, T)
  2228. if LastX and LastY then
  2229. local LookV3 = HRP.CFrame.lookVector
  2230. local LastPos = (Head.CFrame * CF(1.5, 0, 0)).p + (LookV3 * LastX) + VEC3(0, LastY, 0)
  2231. local NewPos = (Head.CFrame * CF(1.5, 0, 0)).p + (LookV3 * XPos) + VEC3(0, YPos, 0)
  2232. local LineCF = CF(LastPos, NewPos)
  2233. local Dist = (LastPos - NewPos).magnitude
  2234. local NewDist = Dist
  2235.  
  2236. local H, P = AdvRayCast(LastPos, (NewPos - LastPos), 1, {Camera, unpack(Ignore)})
  2237. if H then
  2238. NewDist = (P - LastPos).magnitude
  2239.  
  2240. local SurfaceCF = GetHitSurfaceCFrame(P, H)
  2241. local SurfaceDir = CF(H.CFrame.p, SurfaceCF.p)
  2242. local SurfaceDist = SurfaceDir.lookVector * (H.CFrame.p - SurfaceCF.p).magnitude / 2
  2243. local SurfaceOffset = P - SurfaceCF.p + SurfaceDist
  2244. local SurfaceCFrame = SurfaceDir + SurfaceDist + SurfaceOffset
  2245.  
  2246. Target:SetPrimaryPartCFrame(SurfaceCFrame * CFANG(RAD(-90), 0, 0))
  2247.  
  2248. Target.Parent = Camera
  2249. else
  2250. Target.Parent = nil
  2251. end
  2252.  
  2253. local Line = Instance.new("Part")
  2254. Line.BrickColor = BrickColor.Red()
  2255. Line.Material = Enum.Material.SmoothPlastic
  2256. Line.Transparency = 0.2 + ((math.sin(X) + 1) / 5)
  2257. Line.Anchored = true
  2258. Line.CanCollide = false
  2259. Line.FormFactor = Enum.FormFactor.Custom
  2260. Line.Size = Vector3.new(0.4, 0.4, NewDist)
  2261. Line.TopSurface = Enum.SurfaceType.Smooth
  2262. Line.BottomSurface = Enum.SurfaceType.Smooth
  2263. Line.CFrame = LineCF + (LineCF.lookVector * NewDist / 2)
  2264. Line.Parent = Camera
  2265.  
  2266. table.insert(Lines, Line)
  2267.  
  2268. LastX,LastY = XPos,YPos
  2269.  
  2270. if H then break end
  2271. else
  2272. LastX,LastY = XPos,YPos
  2273. end
  2274. end
  2275.  
  2276. wait()
  2277.  
  2278. for _,Line in pairs(Lines) do
  2279. Line:Destroy()
  2280. end
  2281. end
  2282.  
  2283. Target:Destroy()
  2284. end)
  2285. end
  2286.  
  2287. local AnimTable = {
  2288. function()
  2289. TweenJoint(LWeld, CF(-1.5, 0, 0), CF(0, 0.6, 0), Linear, 0.2)
  2290. TweenJoint(RWeld, CF(1.5, 0, 0) * CFANG(0, 0, RAD(-10)), CF(0, 0.6, 0), Linear, 0.2)
  2291. TweenJoint(Grip, Grip.C0, CFANG(0, RAD(10), 0), Linear, 0.2)
  2292. wait(0.3)
  2293. end;
  2294.  
  2295. function()
  2296. Grip.Part0 = Torso
  2297. Grip.C1 = CF(-1, 0.5, -0.5)
  2298.  
  2299. if S.LethalGrenadeType == 3 and Type == 1 then
  2300. Grenade0 = CreateKnife()
  2301. Grenade0.Parent = Gun_Ignore
  2302.  
  2303. local Weld = Instance.new("Weld")
  2304. Weld.Part0 = FakeRArm
  2305. Weld.Part1 = Grenade0
  2306. Weld.C0 = Grip.C0
  2307. Weld.C1 = CF(0, 0, -0.5) * CFANG(RAD(90), RAD(90), 0)
  2308. Weld.Parent = Grenade0
  2309.  
  2310. TweenJoint(LWeld2, CF(), CF(), Sine, 0.3)
  2311. TweenJoint(RWeld2, CF(), CF(), Sine, 0.3)
  2312. TweenJoint(LWeld, ArmC0[1], CF(0, 0.5, 0.1) * CFANG(RAD(90), 0, 0), Sine, 0.3)
  2313. TweenJoint(RWeld, ArmC0[2], CF(0, 0.4, 0.1) * CFANG(RAD(-80), 0, 0), Sine, 0.3)
  2314. wait(0.3)
  2315. else
  2316. Grenade0 = CreateGrenade()
  2317. Grenade0.Parent = Gun_Ignore
  2318.  
  2319. local Weld = Instance.new("Weld")
  2320. Weld.Part0 = FakeRArm
  2321. Weld.Part1 = Grenade0:WaitForChild("Center")
  2322. Weld.C0 = Grip.C0
  2323. Weld.Parent = Grenade0:WaitForChild("Center")
  2324.  
  2325. TweenJoint(LWeld2, CF(), CFANG(0, RAD(80), 0), Linear, 0.25)
  2326. TweenJoint(RWeld2, CF(), CFANG(0, RAD(-80), 0), Linear, 0.25)
  2327. TweenJoint(LWeld, ArmC0[1], CF(-0.2, 0.8, 0.1) * CFANG(RAD(10), 0, RAD(-30)), Linear, 0.25)
  2328. TweenJoint(RWeld, ArmC0[2], CF(0.2, 0.8, 0.1) * CFANG(RAD(10), 0, RAD(30)), Linear, 0.25)
  2329. wait(0.3)
  2330. end
  2331. end;
  2332.  
  2333. function()
  2334. repeat wait() until (not Keys[S.LethalGrenadeKey]) and (not Keys[S.TacticalGrenadeKey]) or (not Selected)
  2335. end;
  2336.  
  2337. function()
  2338. if S.LethalGrenadeType ~= 3 or Type == 2 then
  2339. TweenJoint(LWeld2, CF(), CFANG(0, RAD(45), 0), Sine, 0.2)
  2340. TweenJoint(RWeld2, CF(), CFANG(0, RAD(-45), 0), Sine, 0.2)
  2341. TweenJoint(LWeld, ArmC0[1], CF(0, 0.8, 0.1), Sine, 0.2)
  2342. TweenJoint(RWeld, ArmC0[2], CF(0, 0.8, 0.1), Sine, 0.2)
  2343. wait(0.2)
  2344. end
  2345. end;
  2346.  
  2347. function()
  2348. if S.LethalGrenadeType ~= 3 or Type == 2 then
  2349. TweenJoint(LWeld2, CF(), CF(), Sine, 0.3)
  2350. TweenJoint(RWeld2, CF(), CF(), Sine, 0.3)
  2351. TweenJoint(LWeld, ArmC0[1], CF(0, 0.5, 0.1) * CFANG(RAD(90), 0, 0), Sine, 0.3)
  2352. TweenJoint(RWeld, ArmC0[2], CF(0, 0.4, 0.1) * CFANG(RAD(-80), 0, 0), Sine, 0.3)
  2353. wait(0.3)
  2354. end
  2355. end;
  2356.  
  2357. function()
  2358. TweenJoint(RWeld, ArmC0[2], CF(0, 0.8, 0.1) * CFANG(RAD(-10), 0, 0), Sine, 0.1)
  2359. wait(0.07)
  2360. end;
  2361.  
  2362. function()
  2363. local Main = nil
  2364. Grenade0:Destroy()
  2365.  
  2366. if S.LethalGrenadeType == 3 and Type == 1 then
  2367. local Grenade1 = CreateKnife()
  2368. Main = Grenade1
  2369.  
  2370. Grenade1.Parent = Gun_Ignore
  2371.  
  2372. Main.CFrame = FakeRArm.CFrame * Grip.C0 * CF(0, 0.5, 0) * CFANG(RAD(-90), 0, RAD(90))
  2373. Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.LethalGrenadeThrowVelocity)
  2374. Main.RotVelocity = (Main.CFrame * CFANG(RAD(90), 0, 0)).lookVector * 20
  2375. else
  2376. local Grenade1 = CreateGrenade()
  2377. Main = Grenade1:WaitForChild("Center")
  2378.  
  2379. local Sound = Instance.new("Sound")
  2380. Sound.SoundId = (Type == 1 and "rbxassetid://180302005" or "rbxassetid://156283116")
  2381. Sound.Volume = 1
  2382. Sound.PlayOnRemove = true
  2383. Sound.Parent = Main
  2384.  
  2385. Grenade1.Parent = Gun_Ignore
  2386.  
  2387. Main.CanCollide = true
  2388. Main.CFrame = FakeRArm.CFrame * Grip.C0
  2389. if Type == 1 then
  2390. Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.LethalGrenadeThrowVelocity)
  2391. elseif Type == 2 then
  2392. Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.TacticalGrenadeThrowVelocity)
  2393. end
  2394. end
  2395.  
  2396. spawn(function()
  2397. if Type == 1 then
  2398. if S.LethalGrenadeType == 1 then
  2399. if S.TimerStartOnHit then
  2400. local Detonated = false
  2401. Main.Touched:connect(function(Obj)
  2402. if IsIgnored(Obj) or Detonated then return end
  2403. Main.Velocity = Main.Velocity / 4
  2404. Detonated = true
  2405.  
  2406. wait(S.DetonationTime)
  2407.  
  2408. DetonateExplosive(Main)
  2409. end)
  2410. else
  2411. spawn(function()
  2412. local Touched = false
  2413. Main.Touched:connect(function(Obj)
  2414. if IsIgnored(Obj) or Touched then return end
  2415. Touched = true
  2416. Main.Velocity = Main.Velocity / 4
  2417. end)
  2418. end)
  2419. wait(S.DetonationTime)
  2420. DetonateExplosive(Main)
  2421. end
  2422. elseif S.LethalGrenadeType == 2 then
  2423. local Detonated = false
  2424. local GrenadeCF = nil
  2425. Main.Touched:connect(function(Obj)
  2426. if IsIgnored(Obj) or Detonated then return end
  2427. GrenadeCF = Main.CFrame
  2428.  
  2429. local W = Instance.new("Weld")
  2430. W.Name = "Semtex"
  2431. W.Part0 = Main
  2432. W.Part1 = Obj
  2433. W.C0 = GrenadeCF:toObjectSpace(Obj.CFrame)
  2434. W.Parent = Main
  2435.  
  2436. Main.ChildRemoved:connect(function(C)
  2437. if C.Name == "Semtex" then
  2438. local W = Instance.new("Weld")
  2439. W.Name = "Semtex"
  2440. W.Part0 = Main
  2441. W.Part1 = Obj
  2442. W.C0 = GrenadeCF:toObjectSpace(Obj.CFrame)
  2443. W.Parent = Main
  2444. end
  2445. end)
  2446.  
  2447. if S.TimerStartOnHit then
  2448. Detonated = true
  2449. wait(S.DetonationTime)
  2450. DetonateExplosive(Main)
  2451. end
  2452. end)
  2453.  
  2454. if (not S.TimerStartOnHit) then
  2455. wait(S.DetonationTime)
  2456. Detonated = true
  2457. DetonateExplosive(Main)
  2458. end
  2459. elseif S.LethalGrenadeType == 3 then
  2460. local Touched = false
  2461. Main.Touched:connect(function(Obj)
  2462. if IsIgnored(Obj) or Touched then return end
  2463. Touched = true
  2464.  
  2465. local W = Instance.new("Weld")
  2466. W.Name = "Sticky"
  2467. W.Part0 = Main
  2468. W.Part1 = Obj
  2469. W.C0 = Main.CFrame:toObjectSpace(Obj.CFrame)
  2470. W.Parent = Main
  2471.  
  2472. Main.ChildRemoved:connect(function(C)
  2473. if C.Name == "Sticky" then
  2474. local W = Instance.new("Weld")
  2475. W.Name = "Sticky"
  2476. W.Part0 = Main
  2477. W.Part1 = Obj
  2478. W.C0 = Main.CFrame:toObjectSpace(Obj.CFrame)
  2479. W.Parent = Main
  2480. end
  2481. end)
  2482.  
  2483. if Obj then
  2484. if Obj.Parent.ClassName == "Hat" then
  2485. local HitHumanoid = FindFirstClass(Obj.Parent.Parent, "Humanoid")
  2486. if HitHumanoid and IsEnemy(HitHumanoid) then
  2487. local CreatorTag = Instance.new("ObjectValue")
  2488. CreatorTag.Name = "creator"
  2489. CreatorTag.Value = Player
  2490. CreatorTag.Parent = HitHumanoid
  2491. HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
  2492. MarkHit()
  2493. end
  2494. else
  2495. local HitHumanoid = FindFirstClass(Obj.Parent, "Humanoid")
  2496. if HitHumanoid and IsEnemy(HitHumanoid) then
  2497. local CreatorTag = Instance.new("ObjectValue")
  2498. CreatorTag.Name = "creator"
  2499. CreatorTag.Value = Player
  2500. CreatorTag.Parent = HitHumanoid
  2501. HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
  2502. MarkHit()
  2503. end
  2504. end
  2505. end
  2506.  
  2507. wait(3)
  2508.  
  2509. Main:Destroy()
  2510. end)
  2511. end
  2512. elseif Type == 2 then
  2513. if S.TacticalGrenadeType == 1 then
  2514. if S.TimerStartOnHit then
  2515. local Detonated = false
  2516. Main.Touched:connect(function(Obj)
  2517. if IsIgnored(Obj) or Detonated then return end
  2518. Main.Velocity = Main.Velocity / 2
  2519. Detonated = true
  2520.  
  2521. wait(S.DetonationTime)
  2522.  
  2523. DetonateSmoke(Main)
  2524. end)
  2525. else
  2526. spawn(function()
  2527. local Touched = false
  2528. Main.Touched:connect(function(Obj)
  2529. if IsIgnored(Obj) or Touched then return end
  2530. Touched = true
  2531. Main.Velocity = Main.Velocity / 2
  2532. end)
  2533. end)
  2534. wait(S.DetonationTime)
  2535. DetonateSmoke(Main)
  2536. end
  2537. end
  2538. end
  2539. end)
  2540.  
  2541. if S.GrenadeTrail and S.GrenadeTrailTransparency ~= 1 then
  2542. spawn(function()
  2543. local LastPos = nil
  2544. while true do
  2545. if LastPos then
  2546. if (not Main:IsDescendantOf(game))
  2547. or (Main.Name == "Knife" and FindFirstClass(Main, "Weld")) then
  2548. break
  2549. end
  2550. local Trail = Instance.new("Part")
  2551. Trail.BrickColor = S.GrenadeTrailColor
  2552. Trail.Transparency = S.GrenadeTrailTransparency
  2553. Trail.Anchored = true
  2554. Trail.CanCollide = false
  2555. Trail.Size = VEC3(1, 1, 1)
  2556. local Mesh = Instance.new("BlockMesh")
  2557. Mesh.Offset = VEC3(0, 0, -(Main.Position - LastPos).magnitude / 2)
  2558. Mesh.Scale = VEC3(S.GrenadeTrailThickness, S.GrenadeTrailThickness, (Main.Position - LastPos).magnitude)
  2559. Mesh.Parent = Trail
  2560. Trail.Parent = Gun_Ignore
  2561. Trail.CFrame = CF(LastPos, Main.Position)
  2562. delay(S.GrenadeTrailVisibleTime, function()
  2563. if S.GrenadeTrailDisappearTime > 0 then
  2564. local X = 0
  2565. while true do
  2566. if X == 90 then break end
  2567. if (not Selected) then break end
  2568. local NewX = X + (1.5 / S.GrenadeTrailDisappearTime)
  2569. X = (NewX > 90 and 90 or NewX)
  2570. local Alpha = X / 90
  2571. Trail.Transparency = NumLerp(S.GrenadeTrailTransparency, 1, Alpha)
  2572. RS:wait()
  2573. end
  2574. Trail:Destroy()
  2575. else
  2576. Trail:Destroy()
  2577. end
  2578. end)
  2579. LastPos = Main.Position
  2580. else
  2581. LastPos = Main.Position
  2582. end
  2583. RS:wait()
  2584. end
  2585. end)
  2586. end
  2587. wait(0.2)
  2588. end;
  2589.  
  2590. function()
  2591. TweenJoint(RWeld, CF(1.5, 0, 0) * CFANG(0, 0, RAD(-10)), CF(0, 0.6, 0), Linear, 0.2)
  2592. wait(0.3)
  2593. end;
  2594.  
  2595. function()
  2596. Grip.Part0 = RArm
  2597. Grip.C1 = CFANG(0, RAD(20), 0)
  2598.  
  2599. TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Linear, 0.2)
  2600. TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Linear, 0.2)
  2601. wait(0.2)
  2602. end;
  2603. }
  2604.  
  2605. for _,F in pairs(AnimTable) do
  2606. if (not Selected) then
  2607. break
  2608. end
  2609. F()
  2610. end
  2611.  
  2612. if (not Selected) and Grenade0 then
  2613. Grenade0:Destroy()
  2614. end
  2615. end
  2616.  
  2617. --------------------[ CAMERA STEADYING FUNCTIONS ]------------------------------------
  2618.  
  2619. function SteadyCamera()
  2620. Gui_Clone.Scope.Steady.Text = "Steadying..."
  2621. Gui_Clone.Scope.Steady.TextColor3 = Color3.new(1, 1, 0)
  2622. CameraSteady = true
  2623. local OriginalSway = CameraSway
  2624. for X = 0, 90, 1.5 / 0.6 do
  2625. if (not Run_Key_Pressed) then break end
  2626. local Alpha = SIN(RAD(X))
  2627. CameraSway = NumLerp(OriginalSway, 0, Alpha)
  2628. RS:wait()
  2629. end
  2630. while Run_Key_Pressed and Aimed do
  2631. if CurrentSteadyTime > 0 then
  2632. local NewSteadyTime = CurrentSteadyTime - 1
  2633. CurrentSteadyTime = (NewSteadyTime < 0 and 0 or NewSteadyTime)
  2634. CameraSway = 0
  2635. elseif CurrentSteadyTime == 0 then
  2636. break
  2637. end
  2638. RS:wait()
  2639. end
  2640. CameraSteady = false
  2641. spawn(function()
  2642. for X = 0, 90, 1.5 / 0.2 do
  2643. local Alpha = math.log10(X) / math.log10(90)
  2644. CameraSway = NumLerp(0, 3, Alpha)
  2645. RS:wait()
  2646. end
  2647. for X = 0, 90, 1.5 / S.ScopeSteadyTime do
  2648. if CameraSteady then break end
  2649. local Alpha = SIN(RAD(X))
  2650. CameraSway = NumLerp(3, 1, Alpha)
  2651. RS:wait()
  2652. end
  2653. end)
  2654. RetakeBreath()
  2655. end
  2656.  
  2657. function RetakeBreath()
  2658. local Steady = Gui_Clone.Scope.Steady
  2659. Steady.Text = "Re-taking Breath"
  2660. Steady.TextColor3 = Color3.new(1, 0, 0)
  2661. TakingBreath = true
  2662. while TakingBreath do
  2663. if CurrentSteadyTime < MaxSteadyTime then
  2664. local NewSteadyTime = CurrentSteadyTime + (S.ScopeSteadyTime / S.SteadyCooldownTime)
  2665. CurrentSteadyTime = (NewSteadyTime > MaxSteadyTime and MaxSteadyTime or NewSteadyTime)
  2666. elseif CurrentSteadyTime >= MaxSteadyTime then
  2667. break
  2668. end
  2669. RS:wait()
  2670. end
  2671. if TakingBreath then
  2672. Steady.Text = "Hold "..ConvertKey(S.ScopeSteadyKey).." to Steady"
  2673. Steady.TextColor3 = Color3.new(1, 1, 0)
  2674. TakingBreath = false
  2675. end
  2676. end
  2677.  
  2678. --------------------[ SPRINTING FUNCTIONS ]-------------------------------------------
  2679.  
  2680. function MonitorStamina()
  2681. while Run_Key_Pressed do
  2682. if (not Aimed) and (not Aiming) then
  2683. break
  2684. end
  2685. RS:wait()
  2686. end
  2687. while Run_Key_Pressed and (not Aiming) and (not Aimed) and (not Knifing) and (not ThrowingGrenade) do
  2688. local Forward = (Keys["w"] or Keys[string.char(17)])
  2689. local Backward = (Keys["s"] or Keys[string.char(18)])
  2690. if (Forward and (not Backward))
  2691. and Walking and (Stamina > 0) then
  2692. if Stance == 1 or Stance == 2 then Stand() end
  2693. local NewStamina = Stamina - 1
  2694. Stamina = (NewStamina < 0 and 0 or NewStamina)
  2695. Running = true
  2696. elseif (not (Forward and (not Backward)))
  2697. or (not Walking) or (Stamina == 0) then
  2698. break
  2699. end
  2700. RS:wait()
  2701. end
  2702. Running = false
  2703. RechargeStamina()
  2704. end
  2705.  
  2706. function RechargeStamina()
  2707. ChargingStamina = true
  2708. while ((not Run_Key_Pressed) or (Stamina < MaxStamina)) and (not Running) do
  2709. if Stamina < MaxStamina then
  2710. local NewStamina = Stamina + (S.SprintTime / S.StaminaCoolTime)
  2711. Stamina = (NewStamina > MaxStamina and MaxStamina or NewStamina)
  2712. elseif Stamina >= MaxStamina then
  2713. break
  2714. end
  2715. RS:wait()
  2716. end
  2717. ChargingStamina = false
  2718. end
  2719.  
  2720. --------------------[ STANCE FUNCTIONS ]----------------------------------------------
  2721.  
  2722. function Stand(OnDeselected)
  2723. local LHip = Torso["Left Hip"]
  2724. local RHip = Torso["Right Hip"]
  2725. local Root = HRP.RootJoint
  2726. Stance = 0
  2727. if S.StanceAnimation and (not OnDeselected) then
  2728. spawn(function()
  2729. local PreviousOffset = Humanoid.CameraOffset
  2730. local PreviousRootP = Root.C0.p
  2731. for X = 0, 90, 1.5 / S.StanceChangeSpeed do
  2732. if Stance ~= 0 then break end
  2733. local Alpha = Sine(X)
  2734. Humanoid.CameraOffset = PreviousOffset:lerp(StanceOffset[1], Alpha)
  2735. Root.C0 = CF(PreviousRootP:lerp(VEC3(), Alpha)) * CFANG(RAD(-90), 0, RAD(180))
  2736. RS:wait()
  2737. end
  2738. end)
  2739. TweenJoint(ABWeld, CF(), CF(), Sine, S.StanceChangeSpeed)
  2740. TweenJoint(LHip, CF(-1, -1, 0) * CFANG(0, RAD(-90), 0), CF(-0.5, 1, 0) * CFANG(0, RAD(-90), 0), Sine, S.StanceChangeSpeed)
  2741. TweenJoint(RHip, CF(1, -1, 0) * CFANG(RAD(-180), RAD(90), 0), CF(0.5, 1, 0) * CFANG(RAD(-180), RAD(90), 0), Sine, S.StanceChangeSpeed)
  2742. elseif OnDeselected then
  2743. Humanoid.CameraOffset = StanceOffset[1]
  2744. ABWeld.C0 = CF()
  2745. ABWeld.C1 = CF()
  2746. LHip.C0 = CF(-1, -1, 0) * CFANG(0, RAD(-90), 0)
  2747. LHip.C1 = CF(-0.5, 1, 0) * CFANG(0, RAD(-90), 0)
  2748. RHip.C0 = CF(1, -1, 0) * CFANG(RAD(-180), RAD(90), 0)
  2749. RHip.C1 = CF(0.5, 1, 0) * CFANG(RAD(-180), RAD(90), 0)
  2750. Root.C0 = CFANG(RAD(-90), 0, RAD(180))
  2751. end
  2752. end
  2753.  
  2754. function Crouch()
  2755. local LHip = Torso["Left Hip"]
  2756. local RHip = Torso["Right Hip"]
  2757. local Root = HRP.RootJoint
  2758. Stance = 1
  2759. if S.StanceAnimation then
  2760. spawn(function()
  2761. local PreviousOffset = Humanoid.CameraOffset
  2762. local PreviousRootP = Root.C0.p
  2763. for X = 0, 90, 1.5 / S.StanceChangeSpeed do
  2764. if Stance ~= 1 then break end
  2765. local Alpha = Sine(X)
  2766. Humanoid.CameraOffset = PreviousOffset:lerp(StanceOffset[2], Alpha)
  2767. Root.C0 = CF(PreviousRootP:lerp(VEC3(0, -1, 0), Alpha)) * CFANG(RAD(-90), 0, RAD(180))
  2768. RS:wait()
  2769. end
  2770. end)
  2771. TweenJoint(ABWeld, CF(0, 0, -1 / 16), CF(), Sine, S.StanceChangeSpeed)
  2772. TweenJoint(LHip, CF(-1, -0.5, 0) * CFANG(0, RAD(-90), 0), CF(-0.5, 0.5, 1) * CFANG(0, RAD(-90), RAD(-90)), Sine, S.StanceChangeSpeed)
  2773. TweenJoint(RHip, CF(1, -0.5, 0.25) * CFANG(RAD(-180), RAD(90), 0), CF(0.5, 0.5, 1) * CFANG(RAD(-180), RAD(90), 0), Sine, S.StanceChangeSpeed)
  2774. else
  2775. Humanoid.CameraOffset = StanceOffset[2]
  2776. ABWeld.C0 = CF(0, 0, -1 / 16)
  2777. ABWeld.C1 = CF()
  2778. LHip.C0 = CF(-1, -0.5, 0) * CFANG(0, RAD(-90), 0)
  2779. LHip.C1 = CF(-0.5, 0.5, 1) * CFANG(0, RAD(-90), RAD(-90))
  2780. RHip.C0 = CF(1, -0.5, 0.25) * CFANG(RAD(-180), RAD(90), 0)
  2781. RHip.C1 = CF(0.5, 0.5, 1) * CFANG(RAD(-180), RAD(90), 0)
  2782. Root.C0 = CF(0, -1, 0) * CFANG(RAD(-90), 0, RAD(180))
  2783. end
  2784. end
  2785.  
  2786. function Prone()
  2787. local LHip = Torso["Left Hip"]
  2788. local RHip = Torso["Right Hip"]
  2789. local Root = HRP.RootJoint
  2790. Stance = 2
  2791. if S.StanceAnimation then
  2792. spawn(function()
  2793. local PreviousOffset = Humanoid.CameraOffset
  2794. local PreviousRootP = Root.C0.p
  2795. for X = 0, 90, 1.5 / S.StanceChangeSpeed do
  2796. if Stance ~= 2 then break end
  2797. local Alpha = Sine(X)
  2798. Humanoid.CameraOffset = PreviousOffset:lerp(StanceOffset[3], Alpha)
  2799. Root.C0 = CF(PreviousRootP:lerp(VEC3(0, -2.5, 1), Alpha)) * CFANG(RAD(180), 0, RAD(180))
  2800. RS:wait()
  2801. end
  2802. end)
  2803. TweenJoint(ABWeld, CF(0, 0, -1 / 8), CF(), Sine, S.StanceChangeSpeed)
  2804. TweenJoint(LHip, CF(-1, -1, 0) * CFANG(0, RAD(-90), 0), CF(-0.5, 1, 0) * CFANG(0, RAD(-90), 0), Sine, S.StanceChangeSpeed)
  2805. TweenJoint(RHip, CF(1, -1, 0) * CFANG(RAD(-180), RAD(90), 0), CF(0.5, 1, 0) * CFANG(RAD(-180), RAD(90), 0), Sine, S.StanceChangeSpeed)
  2806. else
  2807. Humanoid.CameraOffset = StanceOffset[3]
  2808. ABWeld.C0 = CF(0, 0, -1 / 8)
  2809. ABWeld.C1 = CF()
  2810. LHip.C0 = CF(-1, -1, 0) * CFANG(0, RAD(-90), 0)
  2811. LHip.C1 = CF(-0.5, 1, 0) * CFANG(0, RAD(-90), 0)
  2812. RHip.C0 = CF(1, -1, 0) * CFANG(RAD(-180), RAD(90), 0)
  2813. RHip.C1 = CF(0.5, 1, 0) * CFANG(RAD(-180), RAD(90), 0)
  2814. Root.C0 = CF(0, -2.5, 1) * CFANG(RAD(180), 0, RAD(180))
  2815. end
  2816. end
  2817.  
  2818. function Dive(Speed)
  2819. local DiveVelocity = (HRP.CFrame * CFANG(RAD(18),0,0)).lookVector * Speed * (35 / 16) * 4e3
  2820. HRP.Velocity = VEC3()
  2821. Torso.Velocity = VEC3()
  2822. local BF = Instance.new("BodyForce")
  2823. BF.force = DiveVelocity
  2824. BF.Parent = HRP
  2825. delay(0.05, function()
  2826. Prone()
  2827. local Start = tick()
  2828. while true do
  2829. wait()
  2830. if (tick() - Start) > 0.1 then break end
  2831. BF.force = -HRP.Velocity * 700
  2832. end
  2833. BF:Destroy()
  2834. end)
  2835. end
  2836.  
  2837. --------------------[ KEYBOARD FUNCTIONS ]--------------------------------------------
  2838.  
  2839. function KeyDown(K)
  2840. local Key = string.lower(K)
  2841.  
  2842. if Key == S.LowerStanceKey and S.CanChangeStance then
  2843. if (not Running) then
  2844. if Stance == 0 then
  2845. Crouch()
  2846. elseif Stance == 1 then
  2847. Prone()
  2848. end
  2849. elseif S.DolphinDive then
  2850. delay(1 / 30,function()
  2851. CanRun = false
  2852. Dive(S.BaseWalkSpeed)
  2853. Run_Key_Pressed = false
  2854. wait(S.DiveRechargeTime)
  2855. CanRun = true
  2856. end)
  2857. end
  2858. end
  2859.  
  2860. if Key == S.RaiseStanceKey and S.CanChangeStance then
  2861. if (not Running) then
  2862. if Stance == 2 then
  2863. Crouch()
  2864. elseif Stance == 1 then
  2865. Stand()
  2866. end
  2867. end
  2868. end
  2869.  
  2870. if Key == S.ADSKey then
  2871. if S.HoldMouseOrKeyToADS then
  2872. if (not AimingIn) and (not Aimed) then
  2873. AimingIn = true
  2874. AimGun()
  2875. AimingIn = false
  2876. end
  2877. else
  2878. if Aimed then
  2879. UnAimGun()
  2880. else
  2881. AimGun()
  2882. end
  2883. end
  2884. end
  2885.  
  2886. if Key == S.ReloadKey then
  2887. if (not Reloading) and (not Running) then
  2888. Reload()
  2889. end
  2890. end
  2891.  
  2892.  
  2893. if Key == S.KnifeKey and S.CanKnife then
  2894. if KnifeReady and (not Knifing) and (not ThrowingGrenade) then
  2895. if Aimed then UnAimGun(true) end
  2896. BreakReload = true
  2897. Knifing = true
  2898. KnifeReady = false
  2899. KnifeAnim()
  2900. BreakReload = false
  2901. Knifing = false
  2902. delay(S.KnifeCooldown, function()
  2903. KnifeReady = true
  2904. end)
  2905. end
  2906. end
  2907.  
  2908. if Key == S.LethalGrenadeKey and S.Throwables then
  2909. if (not Knifing) and (not Running) and (not Aimed) and (not Aiming) and (not ThrowingGrenade) then
  2910. if LethalGrenades.Value > 0 then
  2911. LethalGrenades.Value = LethalGrenades.Value - 1
  2912. ThrowingGrenade = true
  2913. ThrowGrenade(1)
  2914. ThrowingGrenade = false
  2915. end
  2916. end
  2917. end
  2918.  
  2919. if Key == S.TacticalGrenadeKey and S.Throwables then
  2920. if (not Knifing) and (not Running) and (not Aimed) and (not Aiming) and (not ThrowingGrenade) then
  2921. if TacticalGrenades.Value > 0 then
  2922. TacticalGrenades.Value = TacticalGrenades.Value - 1
  2923. ThrowingGrenade = true
  2924. ThrowGrenade(2)
  2925. ThrowingGrenade = false
  2926. end
  2927. end
  2928. end
  2929.  
  2930. if Key == S.SprintKey then
  2931. Run_Key_Pressed = true
  2932. if Aimed and (not Aiming) then
  2933. TakingBreath = false
  2934. SteadyCamera()
  2935. end
  2936. if CanRun then
  2937. if (not Idleing) and Walking and (not Running) and (not Knifing) and (not ThrowingGrenade) then
  2938. if Reloading then BreakReload = true end
  2939. MonitorStamina()
  2940. end
  2941. end
  2942. end
  2943. end
  2944.  
  2945. function KeyUp(K)
  2946. local Key = string.lower(K)
  2947.  
  2948. if Key == S.ADSKey then
  2949. if S.HoldMouseOrKeyToADS then
  2950. if (not AimingOut) and Aimed then
  2951. AimingOut = true
  2952. UnAimGun()
  2953. AimingOut = false
  2954. end
  2955. end
  2956. end
  2957.  
  2958. if Key == S.SprintKey then
  2959. Run_Key_Pressed = false
  2960. Running = false
  2961. if (not ChargingStamina) then
  2962. RechargeStamina()
  2963. end
  2964. end
  2965. end
  2966.  
  2967. --------------------[ END FUNCTIONS ]-------------------------------------------------
  2968.  
  2969. --------------------------------------------------------------------------------------
  2970. --------------------[ TOOL SELECTION AND DESELECTION ]--------------------------------
  2971. --------------------------------------------------------------------------------------
  2972.  
  2973. function OnEquipped(M_Icon)
  2974. wait(math.random(10, 40) / 100)
  2975. if Humanoid.Health ~= 0 and (not Selected) and Gun.Parent == Character then
  2976. Selected = true
  2977.  
  2978. BreakReload = false
  2979.  
  2980. --------------------[ FAILSAFE RESETING ]-------------------------------------
  2981.  
  2982. for _, GM in pairs(Ignore_Model:GetChildren()) do
  2983. if GM.Name == "Gun_Ignore_"..Player.Name then
  2984. GM:Destroy()
  2985. end
  2986. end
  2987.  
  2988. for _,c in pairs(Connections) do
  2989. c:disconnect()
  2990. end
  2991.  
  2992. Connections = {}
  2993.  
  2994. --------------------[ CREATING IGNORE MODELS ]--------------------------------
  2995.  
  2996. Gun_Ignore = Instance.new("Model")
  2997. Gun_Ignore.Name = "Gun_Ignore_"..Player.Name
  2998. Gun_Ignore.Parent = Ignore_Model
  2999.  
  3000. --------------------[ MODIFYING THE PLAYER ]----------------------------------
  3001.  
  3002. M_Icon.Icon = "rbxasset://textures\\Blank.png"
  3003.  
  3004. Gui_Clone = Main_Gui:Clone()
  3005. Gui_Clone.Parent = Player.PlayerGui
  3006.  
  3007. SetUpGui()
  3008.  
  3009. Shoulders.Right.Part1 = nil
  3010. Shoulders.Left.Part1 = nil
  3011.  
  3012. PrevNeckCF.C0 = Neck.C0
  3013. PrevNeckCF.C1 = Neck.C1
  3014.  
  3015. BG = Instance.new("BodyGyro", HRP)
  3016. BG.maxTorque = VEC3(HUGE, HUGE, HUGE)
  3017. BG.Name = "BG"
  3018. BG.P = 1e5
  3019. BG.cframe = CF(Torso.CFrame.p, Torso.CFrame.p + Torso.CFrame.lookVector)
  3020.  
  3021. local PlayerFolder = Instance.new("Model")
  3022. PlayerFolder.Name = "PlayerFolder"
  3023. PlayerFolder.Parent = Gun_Ignore
  3024.  
  3025. local AnimBase = Instance.new("Part")
  3026. AnimBase.Transparency = 1
  3027. AnimBase.Name = "AnimBase"
  3028. AnimBase.CanCollide = false
  3029. AnimBase.FormFactor = Enum.FormFactor.Custom
  3030. AnimBase.Size = VEC3(0.2, 0.2, 0.2)
  3031. AnimBase.BottomSurface = Enum.SurfaceType.Smooth
  3032. AnimBase.TopSurface = Enum.SurfaceType.Smooth
  3033. AnimBase.Parent = PlayerFolder
  3034.  
  3035. AnimWeld = Instance.new("Weld")
  3036. AnimWeld.Part0 = AnimBase
  3037. AnimWeld.Part1 = Head
  3038. AnimWeld.C0 = CF(0, 1, 0)
  3039. AnimWeld.Parent = AnimBase
  3040.  
  3041. local ArmBase = Instance.new("Part")
  3042. ArmBase.Transparency = 1
  3043. ArmBase.Name = "ArmBase"
  3044. ArmBase.CanCollide = false
  3045. ArmBase.FormFactor = Enum.FormFactor.Custom
  3046. ArmBase.Size = VEC3(0.2, 0.2, 0.2)
  3047. ArmBase.BottomSurface = Enum.SurfaceType.Smooth
  3048. ArmBase.TopSurface = Enum.SurfaceType.Smooth
  3049. ArmBase.Parent = PlayerFolder
  3050.  
  3051. ABWeld = Instance.new("Weld")
  3052. ABWeld.Part0 = ArmBase
  3053. ABWeld.Part1 = AnimBase
  3054. ABWeld.Parent = ArmBase
  3055.  
  3056. local LArmBase = Instance.new("Part")
  3057. LArmBase.Transparency = 1
  3058. LArmBase.Name = "LArmBase"
  3059. LArmBase.CanCollide = false
  3060. LArmBase.FormFactor = Enum.FormFactor.Custom
  3061. LArmBase.Size = VEC3(0.2, 0.2, 0.2)
  3062. LArmBase.BottomSurface = Enum.SurfaceType.Smooth
  3063. LArmBase.TopSurface = Enum.SurfaceType.Smooth
  3064. LArmBase.Parent = PlayerFolder
  3065.  
  3066. local RArmBase = Instance.new("Part")
  3067. RArmBase.Transparency = 1
  3068. RArmBase.Name = "RArmBase"
  3069. RArmBase.CanCollide = false
  3070. RArmBase.FormFactor = Enum.FormFactor.Custom
  3071. RArmBase.Size = VEC3(0.2, 0.2, 0.2)
  3072. RArmBase.BottomSurface = Enum.SurfaceType.Smooth
  3073. RArmBase.TopSurface = Enum.SurfaceType.Smooth
  3074. RArmBase.Parent = PlayerFolder
  3075.  
  3076. LWeld = Instance.new("Weld")
  3077. LWeld.Name = "LWeld"
  3078. LWeld.Part0 = ArmBase
  3079. LWeld.Part1 = LArmBase
  3080. LWeld.C0 = ArmC0[1]
  3081. LWeld.C1 = S.ArmC1_UnAimed.Left
  3082. LWeld.Parent = ArmBase
  3083.  
  3084. RWeld = Instance.new("Weld")
  3085. RWeld.Name = "RWeld"
  3086. RWeld.Part0 = ArmBase
  3087. RWeld.Part1 = RArmBase
  3088. RWeld.C0 = ArmC0[2]
  3089. RWeld.C1 = S.ArmC1_UnAimed.Right
  3090. RWeld.Parent = ArmBase
  3091.  
  3092. LWeld2 = Instance.new("Weld")
  3093. LWeld2.Name = "LWeld"
  3094. LWeld2.Part0 = LArmBase
  3095. LWeld2.Part1 = LArm
  3096. LWeld2.Parent = LArmBase
  3097.  
  3098. RWeld2 = Instance.new("Weld")
  3099. RWeld2.Name = "RWeld"
  3100. RWeld2.Part0 = RArmBase
  3101. RWeld2.Part1 = RArm
  3102. RWeld2.Parent = RArmBase
  3103.  
  3104. if S.PlayerArms then
  3105. FakeLArm = LArm:Clone()
  3106. FakeLArm.Parent = PlayerFolder
  3107. FakeLArm.Transparency = S.FakeArmTransparency
  3108. FakeLArm:BreakJoints()
  3109.  
  3110. LArm.Transparency = 1
  3111.  
  3112. local FakeLWeld = Instance.new("Weld")
  3113. FakeLWeld.Part0 = FakeLArm
  3114. FakeLWeld.Part1 = LArm
  3115. FakeLWeld.Parent = FakeLArm
  3116.  
  3117. FakeRArm = RArm:Clone()
  3118. FakeRArm.Parent = PlayerFolder
  3119. FakeRArm.Transparency = S.FakeArmTransparency
  3120. FakeRArm:BreakJoints()
  3121.  
  3122. RArm.Transparency = 1
  3123.  
  3124. local FakeRWeld = Instance.new("Weld")
  3125. FakeRWeld.Part0 = FakeRArm
  3126. FakeRWeld.Part1 = RArm
  3127. FakeRWeld.Parent = FakeRArm
  3128.  
  3129. Instance.new("Humanoid", PlayerFolder)
  3130.  
  3131. for _,Obj in pairs(Character:GetChildren()) do
  3132. if Obj:IsA("CharacterMesh") or Obj:IsA("Shirt") then
  3133. Obj:Clone().Parent = PlayerFolder
  3134. end
  3135. end
  3136. else
  3137. local ArmTable = CreateArms()
  3138. ArmTable[1].Model.Parent = PlayerFolder
  3139. ArmTable[2].Model.Parent = PlayerFolder
  3140.  
  3141. FakeLArm = ArmTable[1].ArmPart
  3142.  
  3143. LArm.Transparency = 1
  3144.  
  3145. local FakeLWeld = Instance.new("Weld")
  3146. FakeLWeld.Part0 = FakeLArm
  3147. FakeLWeld.Part1 = LArm
  3148. FakeLWeld.Parent = FakeLArm
  3149.  
  3150. FakeRArm = ArmTable[2].ArmPart
  3151.  
  3152. RArm.Transparency = 1
  3153.  
  3154. local FakeRWeld = Instance.new("Weld")
  3155. FakeRWeld.Part0 = FakeRArm
  3156. FakeRWeld.Part1 = RArm
  3157. FakeRWeld.Parent = FakeRArm
  3158. end
  3159.  
  3160. --------------------[ MODIFYING THE GUN ]-------------------------------------
  3161.  
  3162. for _, Tab in pairs(Parts) do
  3163. local Weld = Instance.new("Weld")
  3164. Weld.Name = "MainWeld"
  3165. Weld.Part0 = Handle
  3166. Weld.Part1 = Tab.Obj
  3167. Weld.C0 = Tab.Obj.WeldCF.Value
  3168. Weld.Parent = Handle
  3169. Tab.Weld = Weld
  3170. end
  3171.  
  3172. Grip = RArm:WaitForChild("RightGrip")
  3173.  
  3174. local HandleCF = ArmBase.CFrame * ArmC0[2] * S.ArmC1_Aimed.Right:inverse() * CF(0, -1, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0)
  3175. local HandleOffset = AimPart.CFrame:toObjectSpace(Handle.CFrame)
  3176. Aimed_GripCF = (Head.CFrame * HandleOffset):toObjectSpace(HandleCF)
  3177.  
  3178. --------------------[ CONNECTIONS ]-------------------------------------------
  3179.  
  3180. INSERT(Connections, Humanoid.Died:connect(function()
  3181. OnUnequipped(true)
  3182. end))
  3183.  
  3184. INSERT(Connections, M2.Button1Down:connect(function()
  3185. MB1_Down = true
  3186. if S.GunType.Auto and (not S.GunType.Semi) and (not S.GunType.Burst) then
  3187. if (not CanFire) then return end
  3188. CanFire = false
  3189. if (not Running) and (not Knifing) and (not ThrowingGrenade) then
  3190. CurrentSpread = (
  3191. Aimed and S.Spread.Aimed or
  3192. ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  3193. )
  3194. while MB1_Down and (not Reloading) do
  3195. if Knifing and (not ThrowingGrenade) then break end
  3196. if Running then break end
  3197. if Ammo.Value > 0 then
  3198. Ammo.Value = Ammo.Value - 1
  3199. if Humanoid.Health ~= 0 then
  3200. if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
  3201. Run_Key_Pressed = false
  3202. CurrentSteadyTime = 0
  3203. end
  3204. Fire_Gun()
  3205. end
  3206. end
  3207. if Ammo.Value == 0 and S.AutoReload then
  3208. wait(0.2)
  3209. Reload()
  3210. end
  3211. wait(60 / S.FireRate)
  3212. end
  3213. end
  3214. CanFire = true
  3215. elseif (not S.GunType.Auto) and S.GunType.Burst then
  3216. if (not CanFire) then return end
  3217. CanFire = false
  3218. if (not Running) and (not Knifing) and (not ThrowingGrenade) then
  3219. CurrentSpread = (
  3220. Aimed and S.Spread.Aimed or
  3221. ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  3222. )
  3223. for i = 1, S.BurstAmount do
  3224. if Ammo.Value > 0 then
  3225. Ammo.Value = Ammo.Value - 1
  3226. if Humanoid.Health ~= 0 then
  3227. if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
  3228. Run_Key_Pressed = false
  3229. CurrentSteadyTime = 0
  3230. end
  3231. Fire_Gun()
  3232. end
  3233. end
  3234. if Ammo.Value == 0 and S.AutoReload then
  3235. wait(0.2)
  3236. Reload()
  3237. break
  3238. end
  3239. wait(S.BurstTime / S.BurstAmount)
  3240. end
  3241. end
  3242. wait(S.BurstWait)
  3243. CanFire = true
  3244. elseif (not S.GunType.Auto) and S.GunType.Semi then
  3245. if (not CanFire) then return end
  3246. CanFire = false
  3247. if (not Running) and (not Knifing) and (not ThrowingGrenade) then
  3248. CurrentSpread = (
  3249. Aimed and S.Spread.Aimed or
  3250. ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  3251. )
  3252. if Ammo.Value > 0 then
  3253. Ammo.Value = Ammo.Value - 1
  3254. if Humanoid.Health ~= 0 then
  3255. if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
  3256. Run_Key_Pressed = false
  3257. CurrentSteadyTime = 0
  3258. end
  3259. Fire_Gun()
  3260. end
  3261. end
  3262. if Ammo.Value == 0 and S.AutoReload then
  3263. wait(0.2)
  3264. Reload()
  3265. end
  3266. wait(60 / S.FireRate)
  3267. end
  3268. CanFire = true
  3269. elseif (not S.GunType.Auto) and (not S.GunType.Semi) and (not S.GunType.Burst) and S.GunType.Shot then
  3270. if (not CanFire) then return end
  3271. CanFire = false
  3272. if (not Running) and (not Knifing) and (not ThrowingGrenade) then
  3273. CurrentSpread = (
  3274. Aimed and S.Spread.Aimed or
  3275. ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  3276. )
  3277. if Ammo.Value > 0 then
  3278. Ammo.Value = Ammo.Value - 1
  3279. if Humanoid.Health ~= 0 then
  3280. if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
  3281. Run_Key_Pressed = false
  3282. CurrentSteadyTime = 0
  3283. end
  3284. Fire_Gun()
  3285. end
  3286. end
  3287. if Ammo.Value == 0 and S.AutoReload then
  3288. wait(0.2)
  3289. Reload()
  3290. end
  3291. wait(60 / S.FireRate)
  3292. end
  3293. CanFire = true
  3294. elseif (not S.GunType.Auto) and (not S.GunType.Semi) and S.GunType.Burst and (not S.GunType.Shot) then
  3295. if (not CanFire) then return end
  3296. CanFire = false
  3297. if (not Running) and (not Knifing) and (not ThrowingGrenade) then
  3298. CurrentSpread = (
  3299. Aimed and S.Spread.Aimed or
  3300. ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  3301. )
  3302. for i = 1, S.BurstAmount do
  3303. if Ammo.Value > 0 then
  3304. Ammo.Value = Ammo.Value - 1
  3305. if Humanoid.Health ~= 0 then
  3306. if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
  3307. Run_Key_Pressed = false
  3308. CurrentSteadyTime = 0
  3309. end
  3310. Fire_Gun()
  3311. end
  3312. end
  3313. if Ammo.Value == 0 and S.AutoReload then
  3314. wait(0.2)
  3315. Reload()
  3316. break
  3317. end
  3318. wait(S.BurstTime / S.BurstAmount)
  3319. end
  3320. end
  3321. wait(S.BurstWait)
  3322. CanFire = true
  3323. elseif (not S.GunType.Auto) and (not S.GunType.Burst) and (not S.GunType.Shot) and S.GunType.Explosive then
  3324. if (not CanFire) then return end
  3325. CanFire = false
  3326. if (not Running) and (not Knifing) and (not ThrowingGrenade) then
  3327. CurrentSpread = (
  3328. Aimed and S.Spread.Aimed or
  3329. ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  3330. )
  3331. if Ammo.Value > 0 then
  3332. Ammo.Value = Ammo.Value - 1
  3333. if Humanoid.Health ~= 0 then
  3334. if Aimed and Run_Key_Pressed and S.UnSteadyOnFire then
  3335. Run_Key_Pressed = false
  3336. CurrentSteadyTime = 0
  3337. end
  3338. Fire_Gun()
  3339. end
  3340. end
  3341. if Ammo.Value == 0 and S.AutoReload then
  3342. wait(0.2)
  3343. Reload()
  3344. end
  3345. wait(60 / S.FireRate)
  3346. end
  3347. CanFire = true
  3348. end
  3349. end))
  3350.  
  3351. INSERT(Connections, M2.Button1Up:connect(function()
  3352. MB1_Down = false
  3353. CurrentSpread = (
  3354. Aimed and S.Spread.Aimed or
  3355. ((Idleing and (not Walking)) and S.Spread.Hipfire or S.Spread.Walking)
  3356. )
  3357. end))
  3358.  
  3359. INSERT(Connections, M2.Button2Down:connect(function()
  3360. if S.HoldMouseOrKeyToADS then
  3361. if (not AimingIn) and (not Aimed) then
  3362. AimingIn = true
  3363. AimGun()
  3364. AimingIn = false
  3365. end
  3366. else
  3367. if Aimed then
  3368. UnAimGun()
  3369. else
  3370. AimGun()
  3371. end
  3372. end
  3373. end))
  3374.  
  3375. INSERT(Connections, M2.Button2Up:connect(function()
  3376. if S.HoldMouseOrKeyToADS then
  3377. if (not AimingOut) and Aimed then
  3378. AimingOut = true
  3379. UnAimGun()
  3380. AimingOut = false
  3381. end
  3382. end
  3383. end))
  3384.  
  3385. INSERT(Connections, M2.KeyDown:connect(KeyDown))
  3386.  
  3387. INSERT(Connections, M2.KeyUp:connect(KeyUp))
  3388.  
  3389. INSERT(Connections, RS:connect(function()
  3390. local CrossHair = Gui_Clone:WaitForChild("CrossHair")
  3391. local HitMarker = Gui_Clone:WaitForChild("HitMarker")
  3392. local HUD = Gui_Clone:WaitForChild("HUD")
  3393.  
  3394. CrossHair.Position = UDim2.new(0, M2.X, 0, M2.Y)
  3395. HitMarker.Position = UDim2.new(0, M2.X - 13, 0, M2.Y - 13)
  3396.  
  3397. local Clip_Ammo_L = HUD:WaitForChild("Ammo"):WaitForChild("Clip")
  3398. local Stored_Ammo_L = HUD:WaitForChild("Ammo"):WaitForChild("Stored")
  3399. Clip_Ammo_L.Text = Ammo.Value
  3400. Clip_Ammo_L.TextColor3 = (Ammo.Value <= (ClipSize.Value / 3) and Color3.new(1, 0, 0) or Color3.new(1, 1, 1))
  3401. Stored_Ammo_L.Text = StoredAmmo.Value
  3402. Stored_Ammo_L.TextColor3 = (StoredAmmo.Value <= (ClipSize.Value * 2) and Color3.new(1, 0, 0) or Color3.new(1, 1, 1))
  3403.  
  3404. local Lethal_Grenade_Num_L = HUD:WaitForChild("Grenades"):WaitForChild("Lethals"):WaitForChild("Num")
  3405. Lethal_Grenade_Num_L.Text = LethalGrenades.Value
  3406. Lethal_Grenade_Num_L.TextColor3 = (LethalGrenades.Value < 3 and Color3.new(1, 0, 0) or Color3.new(1, 1, 1))
  3407.  
  3408. local Tactical_Grenade_Num_L = HUD:WaitForChild("Grenades"):WaitForChild("Tacticals"):WaitForChild("Num")
  3409. Tactical_Grenade_Num_L.Text = TacticalGrenades.Value
  3410. Tactical_Grenade_Num_L.TextColor3 = (TacticalGrenades.Value < 3 and Color3.new(1, 0, 0) or Color3.new(1, 1, 1))
  3411.  
  3412. local Mode = HUD:WaitForChild("Mode"):WaitForChild("Main")
  3413. if S.GunType.Auto
  3414. and (not S.GunType.Semi)
  3415. and (not S.GunType.Burst)
  3416. and (not S.GunType.Explosive) then
  3417.  
  3418. Mode.Text = "Auto"
  3419.  
  3420. elseif (not S.GunType.Auto)
  3421. and S.GunType.Burst
  3422. and (not S.GunType.Explosive) then
  3423.  
  3424. Mode.Text = "Burst"
  3425.  
  3426. elseif (not S.GunType.Auto)
  3427. and S.GunType.Semi
  3428. and (not S.GunType.Explosive) then
  3429.  
  3430. Mode.Text = "Semi"
  3431.  
  3432. elseif (not S.GunType.Auto)
  3433. and (not S.GunType.Semi)
  3434. and (not S.GunType.Burst)
  3435. and S.GunType.Shot
  3436. and (not S.GunType.Explosive) then
  3437.  
  3438. Mode.Text = "Shotgun"
  3439.  
  3440. elseif (not S.GunType.Auto)
  3441. and (not S.GunType.Semi)
  3442. and S.GunType.Burst
  3443. and (not S.GunType.Shot)
  3444. and (not S.GunType.Explosive) then
  3445.  
  3446. Mode.Text = "Burst"
  3447.  
  3448. elseif S.GunType.Explosive then
  3449.  
  3450. Mode.Text = "Explosive"
  3451.  
  3452. end
  3453.  
  3454. if tick() - LastBeat > (Humanoid.Health / 75) then
  3455. LastBeat = tick()
  3456. HUD.Health.Tray.Beat:TweenPosition(
  3457. UDim2.new(0, -21, 0, 0),
  3458. Enum.EasingDirection.Out,
  3459. Enum.EasingStyle.Linear,
  3460. 0.7 - ((100 - Humanoid.Health) / 400),
  3461. false,
  3462. function()
  3463. HUD.Health.Tray.Beat.Position = UDim2.new(1, 0, 0, 0)
  3464. end
  3465. )
  3466. end
  3467.  
  3468. HUD.Health.Num.Text = CEIL(Humanoid.Health).."%"
  3469. HUD.Health.Num.TextColor3 = (
  3470. (Humanoid.Health > 200 / 3) and Color3.new(1, 1, 1) or
  3471. (Humanoid.Health <= 200 / 3 and Humanoid.Health > 100 / 3) and Color3.new(1, 1, 0) or
  3472. (Humanoid.Health <= 100 / 3) and Color3.new(1, 0, 0)
  3473. )
  3474. end))
  3475.  
  3476. INSERT(Connections, RS:connect(function()
  3477. local MDir = M2.UnitRay.Direction.unit
  3478.  
  3479. local HRPCF = HRP.CFrame * CF(0, 1.5, 0) * CF(Humanoid.CameraOffset)
  3480. Neck.C0 = Torso.CFrame:toObjectSpace(HRPCF)
  3481.  
  3482. if MDir.y == MDir.y then
  3483. HeadRot = -math.asin(MDir.y)
  3484. Neck.C1 = CFANG(HeadRot,0,0)
  3485.  
  3486. local RotTarget = VEC3(MDir.x,0,MDir.z)
  3487. local Rotation = CF(Torso.Position,Torso.Position + RotTarget)
  3488. BG.cframe = Rotation
  3489.  
  3490. local MouseX = FLOOR((M2.X - M2.ViewSizeX / 2) + 0.5)
  3491. local MouseY = FLOOR((M2.Y - M2.ViewSizeY / 2) + 0.5)
  3492. local AppliedMaxTorque = nil
  3493. if (Camera.CoordinateFrame.p - Head.Position).magnitude < 0.6 then
  3494. if (MouseX >= 50 or MouseX <= -50)
  3495. or (MouseY >= 50 or MouseY <= -50) then
  3496. AppliedMaxTorque = VEC3()
  3497. else
  3498. AppliedMaxTorque = VEC3(HUGE,HUGE,HUGE)
  3499. end
  3500. else
  3501. AppliedMaxTorque = VEC3(HUGE,HUGE,HUGE)
  3502. end
  3503. if (not S.RotateWhileSitting) and Humanoid.Sit then
  3504. AppliedMaxTorque = VEC3()
  3505. end
  3506. BG.maxTorque = AppliedMaxTorque
  3507. end
  3508. end))
  3509.  
  3510. INSERT(Connections, RS:connect(function()
  3511. local Forward = (Keys["w"] or Keys[string.char(17)])
  3512. local Backward = (Keys["s"] or Keys[string.char(18)])
  3513. local Right = (Keys["d"] or Keys[string.char(19)])
  3514. local Left = (Keys["a"] or Keys[string.char(20)])
  3515.  
  3516. local WalkingForward = (Forward and (not Backward))
  3517. local WalkingBackward = ((not Forward) and Backward)
  3518. local WalkingRight = (Right and (not Left))
  3519. local WalkingLeft = ((not Right) and Left)
  3520.  
  3521. ArmTilt = (
  3522. ((WalkingForward or WalkingBackward) and WalkingRight) and 5 or
  3523. ((WalkingForward or WalkingBackward) and WalkingLeft) and -5 or
  3524. ((not (WalkingForward and WalkingBackward)) and WalkingRight) and 10 or
  3525. ((not (WalkingForward and WalkingBackward)) and WalkingLeft) and -10 or 0
  3526. )
  3527. end))
  3528.  
  3529. INSERT(Connections, RS:connect(function()
  3530. if (not Idleing) and Walking then
  3531. if Running then
  3532. Humanoid.WalkSpeed = S.SprintSpeed
  3533. else
  3534. local SpeedRatio = (S.AimedWalkSpeed / S.BaseWalkSpeed)
  3535. if Stance == 0 then
  3536. Humanoid.WalkSpeed = (Aimed and S.AimedWalkSpeed or S.BaseWalkSpeed)
  3537. elseif Stance == 1 then
  3538. Humanoid.WalkSpeed = (Aimed and S.CrouchWalkSpeed * SpeedRatio or S.CrouchWalkSpeed)
  3539. elseif Stance == 2 then
  3540. Humanoid.WalkSpeed = (Aimed and S.ProneWalkSpeed * SpeedRatio or S.ProneWalkSpeed)
  3541. end
  3542. end
  3543. else
  3544. Humanoid.WalkSpeed = 16
  3545. end
  3546.  
  3547. StanceSway = 1 - (0.25 * Stance)
  3548. end))
  3549.  
  3550. --------------------[ ANIMATE GUN ]-------------------------------------------
  3551.  
  3552. Animate()
  3553. end
  3554. end
  3555.  
  3556.  
  3557. function OnUnequipped(DeleteTool)
  3558. if Selected then
  3559. Selected = false
  3560.  
  3561. BreakReload = true
  3562.  
  3563. --------------------[ MODIFYING THE PLAYER ]----------------------------------
  3564.  
  3565. Camera.FieldOfView = 70
  3566.  
  3567. game:GetService("UserInputService").MouseIconEnabled = true
  3568.  
  3569. Gui_Clone:Destroy()
  3570. BG:Destroy()
  3571.  
  3572. RArm.Transparency = 0
  3573. LArm.Transparency = 0
  3574.  
  3575. Shoulders.Right.Part1 = RArm
  3576. Shoulders.Left.Part1 = LArm
  3577.  
  3578. Neck.C0 = PrevNeckCF.C0
  3579. Neck.C1 = PrevNeckCF.C1
  3580.  
  3581. Humanoid.WalkSpeed = 16
  3582.  
  3583. --------------------[ RESETING THE TOOL ]-------------------------------------
  3584.  
  3585. Gun_Ignore:Destroy()
  3586.  
  3587. Aimed = false
  3588.  
  3589. for _, Tab in pairs(Parts) do
  3590. Tab.Weld:Destroy()
  3591. Tab.Weld = nil
  3592. end
  3593.  
  3594. for _,c in pairs(Connections) do
  3595. c:disconnect()
  3596. end
  3597.  
  3598. Connections = {}
  3599.  
  3600. if DeleteTool then
  3601. Camera:ClearAllChildren()
  3602. Gun:Destroy()
  3603. end
  3604.  
  3605. if S.StandOnDeselect and Stance ~= 0 then Stand(true) end
  3606. end
  3607. end
  3608.  
  3609. Gun.Equipped:connect(OnEquipped)
  3610. Gun.Unequipped:connect(function() OnUnequipped(false) end)
  3611.  
  3612. --------------------------------------------------------------------------------------
  3613. --------------------[ END PROGRAM ]---------------------------------------------------
  3614. --------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement