HaloJnZ

Untitled

May 24th, 2025 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 161.19 KB | None | 0 0
  1. local CollectionService = game:GetService("CollectionService")
  2. local HttpService = game:GetService("HttpService")
  3. local GuiService = game:GetService("GuiService")
  4. local RunService = game:GetService("RunService")
  5. local UserInputService = game:GetService("UserInputService")
  6. local TweenService = game:GetService("TweenService")
  7. local Debris = game:GetService("Debris")
  8. local Workspace = game:GetService("Workspace")
  9. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  10. local Players = game:GetService("Players")
  11.  
  12. local Miscs = ReplicatedStorage:WaitForChild("Miscs")
  13. local Modules = ReplicatedStorage:WaitForChild("Modules")
  14. local Events = ReplicatedStorage:WaitForChild("Events")
  15. local Remotes = ReplicatedStorage:WaitForChild("Remotes")
  16.  
  17. local Tool = script.Parent
  18. local AnimationFolder = Tool:WaitForChild("AnimationFolder")
  19. local ValueFolder = Tool:WaitForChild("ValueFolder")
  20.  
  21. local Camera = Workspace.CurrentCamera
  22.  
  23. local Player = Players.LocalPlayer
  24. local Character = Player.Character
  25. if not Character or not Character.Parent then
  26. Character = Player.CharacterAdded:Wait()
  27. end
  28. local Humanoid = Character:WaitForChild("Humanoid")
  29. local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
  30. local Head = Character:WaitForChild("Head")
  31. local Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("UpperTorso")
  32. local LeftArm = Character:FindFirstChild("Left Arm") or Character:FindFirstChild("LeftHand")
  33. local RightArm = Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand")
  34.  
  35. local PlayerGui = Player:WaitForChild("PlayerGui")
  36. local Mouse = Player:GetMouse()
  37. local GunServer = Tool:WaitForChild("GunServer")
  38. local ChangeMagAndAmmo = GunServer:WaitForChild("ChangeMagAndAmmo")
  39. local MarkerEvent = script:WaitForChild("MarkerEvent")
  40.  
  41. local GUI = script:WaitForChild("GunGUI")
  42. local MobileButtons = {
  43. AimButton = GUI.MobileButtons.AimButton,
  44. FireButton = GUI.MobileButtons.FireButton,
  45. SubFireButton = GUI.SubFireButton,
  46. HoldDownButton = GUI.MobileButtons.HoldDownButton,
  47. InspectButton = GUI.MobileButtons.InspectButton,
  48. ReloadButton = GUI.MobileButtons.ReloadButton,
  49. SwitchButton = GUI.MobileButtons.SwitchButton,
  50. MeleeButton = GUI.MobileButtons.MeleeButton,
  51. AltButton = GUI.MobileButtons.AltButton
  52. }
  53.  
  54. local TouchGui
  55. local TouchControlFrame
  56. local JumpButton
  57. if UserInputService.TouchEnabled then
  58. TouchGui = PlayerGui:WaitForChild("TouchGui")
  59. TouchControlFrame = TouchGui:WaitForChild("TouchControlFrame")
  60. JumpButton = TouchControlFrame:WaitForChild("JumpButton")
  61. end
  62.  
  63. local GunVisualEffects = Miscs.GunVisualEffects
  64. local Scanners = Miscs.Scanners
  65.  
  66. local SmokeTrail = require(Modules.SmokeTrail)
  67. local SettingModifier = require(Modules.SettingModifier)
  68. local DamageModule = require(Modules.DamageModule)
  69. local Utilities = require(Modules.Utilities)
  70. local Thread = Utilities.Thread
  71. local ProjectileMotion = Utilities.ProjectileMotion
  72. local Math = Utilities.Math
  73. local Spring = Utilities.Spring
  74. local CloneTable = Utilities.CloneTable
  75. local RotatedRegion3 = Utilities.RotatedRegion3
  76. local RaycastHitbox = Utilities.RaycastHitboxV4
  77. local CreatePacket, DecodePacket = unpack(Utilities.DataPacket)
  78.  
  79. local gunEvent = Events.gunEvent
  80. local gunFunction = Events.gunFunction
  81.  
  82. local InflictTarget = Remotes.InflictTarget
  83. local ShatterGlass = Remotes.ShatterGlass
  84. local VisualizeBeam = Remotes.VisualizeBeam
  85. local VisibleMuzzle = Remotes.VisibleMuzzle
  86.  
  87. local GUID = HttpService:GenerateGUID()
  88. local BindToStepName = "UpdateGun_"..GUID
  89.  
  90. local TopbarOffset = (GUI.IgnoreGuiInset and GuiService:GetGuiInset()) or Vector2.new(0, 0)
  91. local Killzone = GUI.AbsoluteSize.Y + TopbarOffset.Y + 100
  92.  
  93. local TargetMarker = script:WaitForChild("TargetMarker")
  94. local LockedEntity
  95.  
  96. local CommonVariables = {
  97. Equipped = false;
  98. ActuallyEquipped = false;
  99. Enabled = true;
  100. Down = false;
  101. HoldDown = false;
  102. Reloading = false;
  103. CanCancelReload = false;
  104. AimDown = false;
  105. Scoping = false;
  106. Inspecting = false;
  107. Charging = false;
  108. Charged = false;
  109. Overheated = false;
  110. CanBeCooledDown = true;
  111. Switching = false;
  112. Alting = false;
  113. AlreadyHit = false;
  114. CurrentFireRate = 0;
  115. ShootCounts = 0;
  116. CurrentRate = 0;
  117. LastRate = 0;
  118. ElapsedTime = 0;
  119. CasingCount = 0;
  120. LastUpdate = nil;
  121. LastUpdate2 = nil;
  122. Radar = nil;
  123. Beam = nil;
  124. Attach0 = nil;
  125. Attach1 = nil;
  126. Misc = nil;
  127. LaserTrail = nil;
  128. Hitbox = nil;
  129. Hitbox2 = nil;
  130. BoltSegments = {};
  131. Animations = {};
  132. SettingModules = {};
  133. Keyframes = {};
  134. KeyframeConnections = {};
  135. Casings = {};
  136. HitHumanoids = {};
  137. MeleeHitHumanoids = {};
  138. BlockedModels = {};
  139. InitialSensitivity = UserInputService.MouseDeltaSensitivity;
  140. Motor6DInstances = {};
  141. GripId = 0;
  142. DefaultC0 = nil;
  143. DefaultC1 = nil;
  144. Handle2 = nil;
  145. Grip2 = nil;
  146. }
  147. local Variables = {}
  148.  
  149. local IgnoreList = {Camera, Tool, Character}
  150.  
  151. local RegionParams = OverlapParams.new()
  152. RegionParams.FilterType = Enum.RaycastFilterType.Blacklist
  153. RegionParams.FilterDescendantsInstances = IgnoreList
  154. RegionParams.MaxParts = 0
  155. RegionParams.CollisionGroup = "Default"
  156.  
  157. local RayParams = RaycastParams.new()
  158. RayParams.FilterType = Enum.RaycastFilterType.Blacklist
  159. RayParams.FilterDescendantsInstances = IgnoreList
  160. RayParams.IgnoreWater = true
  161.  
  162. local Setting = Tool:WaitForChild("Setting")
  163. local Module = require(Setting)
  164. local ConditionableGunMods = require(Setting:WaitForChild("ConditionableGunMods"))
  165. local CanShootConditions = require(Setting:WaitForChild("CanShootConditions"))
  166. local OnClientShootEvents = require(Setting:WaitForChild("OnClientShootEvents"))
  167.  
  168. if Module.DualWeldEnabled then
  169. CommonVariables.Handle2 = Tool:WaitForChild("Handle2", 2)
  170. if CommonVariables.Handle2 == nil and Module.DualWeldEnabled then error("\"Dual\" setting is enabled but \"Handle2\" is missing!") end
  171. end
  172.  
  173. local Settings = {}
  174. for i, v in pairs(Setting:GetChildren()) do
  175. if v.Name ~= "CanShootConditions" and v.Name ~= "ConditionableGunMods" and v.Name ~= "OnClientShootEvents" then
  176. table.insert(Settings, v)
  177. end
  178. end
  179. table.sort(Settings, function(a, b)
  180. return tonumber(a.Name) < tonumber(b.Name)
  181. end)
  182.  
  183. for i, v in ipairs(Settings) do
  184. table.insert(CommonVariables.SettingModules, require(v))
  185. table.insert(Variables, {
  186. Mag = ValueFolder[i].Mag.Value;
  187. Ammo = ValueFolder[i].Ammo.Value;
  188. Heat = 0;
  189. MaxAmmo = CommonVariables.SettingModules[i].MaxAmmo;
  190. ElapsedCooldownTime = 0;
  191. ChargeLevel = 0;
  192. FireModes = CommonVariables.SettingModules[i].FireModes;
  193. FireMode = 1;
  194. ShotsForDepletion = 0;
  195. ShotID = 0;
  196. HandleIndex = 1;
  197. FireAnimIndex = 1;
  198. LastFireAnimIndex = 1;
  199. AimFireAnimIndex = 1;
  200. AimLastFireAnimIndex = 1;
  201. ShotgunPumpinAnimIndex = 1;
  202. ChargeLevelCap = math.clamp(CommonVariables.SettingModules[i].ChargeLevelCap, 1, 3);
  203. })
  204. end
  205.  
  206. for i, v in ipairs(AnimationFolder:GetChildren()) do
  207. local AnimTable = {}
  208. if CommonVariables.SettingModules[i].EquippedAnimationID ~= nil then
  209. AnimTable.EquippedAnim = v:WaitForChild("EquippedAnim")
  210. AnimTable.EquippedAnim = Humanoid:LoadAnimation(AnimTable.EquippedAnim)
  211. end
  212. if CommonVariables.SettingModules[i].EmptyEquippedAnimationID ~= nil then
  213. AnimTable.EmptyEquippedAnim = v:WaitForChild("EmptyEquippedAnim")
  214. AnimTable.EmptyEquippedAnim = Humanoid:LoadAnimation(AnimTable.EmptyEquippedAnim)
  215. end
  216. if CommonVariables.SettingModules[i].IdleAnimationID ~= nil then
  217. AnimTable.IdleAnim = v:WaitForChild("IdleAnim")
  218. AnimTable.IdleAnim = Humanoid:LoadAnimation(AnimTable.IdleAnim)
  219. end
  220. if CommonVariables.SettingModules[i].EmptyIdleAnimationID ~= nil then
  221. AnimTable.EmptyIdleAnim = v:WaitForChild("EmptyIdleAnim")
  222. AnimTable.EmptyIdleAnim = Humanoid:LoadAnimation(AnimTable.EmptyIdleAnim)
  223. end
  224. if #CommonVariables.SettingModules[i].FireAnimations > 0 then
  225. local FireAnimFolder = v:WaitForChild("FireAnimations")
  226. AnimTable.FireAnims = {}
  227. for ii, vv in ipairs(CommonVariables.SettingModules[i].FireAnimations) do
  228. if vv.FireAnimationID ~= nil then
  229. local Anim = FireAnimFolder:WaitForChild("FireAnim_"..ii)
  230. table.insert(AnimTable.FireAnims, {Humanoid:LoadAnimation(Anim), vv.FireAnimationSpeed})
  231. end
  232. end
  233. end
  234. if #CommonVariables.SettingModules[i].LastFireAnimations > 0 then
  235. local LastFireAnimFolder = v:WaitForChild("LastFireAnimations")
  236. AnimTable.LastFireAnims = {}
  237. for ii, vv in ipairs(CommonVariables.SettingModules[i].LastFireAnimations) do
  238. if vv.LastFireAnimationID ~= nil then
  239. local Anim = LastFireAnimFolder:WaitForChild("LastFireAnim_"..ii)
  240. table.insert(AnimTable.LastFireAnims, {Humanoid:LoadAnimation(Anim), vv.LastFireAnimationSpeed})
  241. end
  242. end
  243. end
  244. if #CommonVariables.SettingModules[i].ShotgunPumpinAnimations > 0 then
  245. local ShotgunPumpinAnimFolder = v:WaitForChild("ShotgunPumpinAnimations")
  246. AnimTable.ShotgunPumpinAnims = {}
  247. for ii, vv in ipairs(CommonVariables.SettingModules[i].ShotgunPumpinAnimations) do
  248. if vv.ShotgunPumpinAnimationID ~= nil then
  249. local Anim = ShotgunPumpinAnimFolder:WaitForChild("ShotgunPumpinAnim_"..ii)
  250. table.insert(AnimTable.ShotgunPumpinAnims, {Humanoid:LoadAnimation(Anim), vv.ShotgunPumpinAnimationSpeed})
  251. end
  252. end
  253. end
  254. if CommonVariables.SettingModules[i].ShotgunClipinAnimationID ~= nil then
  255. AnimTable.ShotgunClipinAnim = v:WaitForChild("ShotgunClipinAnim")
  256. AnimTable.ShotgunClipinAnim = Humanoid:LoadAnimation(AnimTable.ShotgunClipinAnim)
  257. end
  258. if CommonVariables.SettingModules[i].ReloadAnimationID ~= nil then
  259. AnimTable.ReloadAnim = v:WaitForChild("ReloadAnim")
  260. AnimTable.ReloadAnim = Humanoid:LoadAnimation(AnimTable.ReloadAnim)
  261. end
  262. if CommonVariables.SettingModules[i].HoldDownAnimationID ~= nil then
  263. AnimTable.HoldDownAnim = v:WaitForChild("HoldDownAnim")
  264. AnimTable.HoldDownAnim = Humanoid:LoadAnimation(AnimTable.HoldDownAnim)
  265. end
  266. if CommonVariables.SettingModules[i].AimIdleAnimationID ~= nil then
  267. AnimTable.AimIdleAnim = v:WaitForChild("AimIdleAnim")
  268. AnimTable.AimIdleAnim = Humanoid:LoadAnimation(AnimTable.AimIdleAnim)
  269. end
  270. if CommonVariables.SettingModules[i].EmptyAimIdleAnimationID ~= nil then
  271. AnimTable.EmptyAimIdleAnim = v:WaitForChild("EmptyAimIdleAnim")
  272. AnimTable.EmptyAimIdleAnim = Humanoid:LoadAnimation(AnimTable.EmptyAimIdleAnim)
  273. end
  274. if #CommonVariables.SettingModules[i].AimFireAnimations > 0 then
  275. local AimFireAnimFolder = v:WaitForChild("AimFireAnimations")
  276. AnimTable.AimFireAnims = {}
  277. for ii, vv in ipairs(CommonVariables.SettingModules[i].AimFireAnimations) do
  278. if vv.AimFireAnimationID ~= nil then
  279. local Anim = AimFireAnimFolder:WaitForChild("AimFireAnim_"..ii)
  280. table.insert(AnimTable.AimFireAnims, {Humanoid:LoadAnimation(Anim), vv.AimFireAnimationSpeed})
  281. end
  282. end
  283. end
  284. if #CommonVariables.SettingModules[i].AimLastFireAnimations > 0 then
  285. local AimLastFireAnimFolder = v:WaitForChild("AimLastFireAnimations")
  286. AnimTable.AimLastFireAnims = {}
  287. for ii, vv in ipairs(CommonVariables.SettingModules[i].AimLastFireAnimations) do
  288. if vv.AimFireAnimationID ~= nil then
  289. local Anim = AimLastFireAnimFolder:WaitForChild("AimLastFireAnim_"..ii)
  290. table.insert(AnimTable.AimLastFireAnims, {Humanoid:LoadAnimation(Anim), vv.AimLastFireAnimationSpeed})
  291. end
  292. end
  293. end
  294. if CommonVariables.SettingModules[i].AimChargingAnimationID ~= nil then
  295. AnimTable.AimChargingAnim = v:WaitForChild("AimChargingAnim")
  296. AnimTable.AimChargingAnim = Humanoid:LoadAnimation(AnimTable.AimChargingAnim)
  297. end
  298. if CommonVariables.SettingModules[i].TacticalReloadAnimationEnabled and CommonVariables.SettingModules[i].TacticalReloadAnimationID ~= nil then
  299. AnimTable.TacticalReloadAnim = v:WaitForChild("TacticalReloadAnim")
  300. AnimTable.TacticalReloadAnim = Humanoid:LoadAnimation(AnimTable.TacticalReloadAnim)
  301. end
  302. if CommonVariables.SettingModules[i].InspectAnimationEnabled and CommonVariables.SettingModules[i].InspectAnimationID ~= nil then
  303. AnimTable.InspectAnim = v:WaitForChild("InspectAnim")
  304. AnimTable.InspectAnim = Humanoid:LoadAnimation(AnimTable.InspectAnim)
  305. end
  306. if CommonVariables.SettingModules[i].InspectAnimationEnabled and CommonVariables.SettingModules[i].EmptyInspectAnimationID ~= nil then
  307. AnimTable.EmptyInspectAnim = v:WaitForChild("EmptyInspectAnim")
  308. AnimTable.EmptyInspectAnim = Humanoid:LoadAnimation(AnimTable.EmptyInspectAnim)
  309. end
  310. if CommonVariables.SettingModules[i].ShotgunReload and CommonVariables.SettingModules[i].PreShotgunReload and CommonVariables.SettingModules[i].PreShotgunReloadAnimationID ~= nil then
  311. AnimTable.PreShotgunReloadAnim = v:WaitForChild("PreShotgunReloadAnim")
  312. AnimTable.PreShotgunReloadAnim = Humanoid:LoadAnimation(AnimTable.PreShotgunReloadAnim)
  313. end
  314. if CommonVariables.SettingModules[i].MinigunRevUpAnimationID ~= nil then
  315. AnimTable.MinigunRevUpAnim = v:WaitForChild("MinigunRevUpAnim")
  316. AnimTable.MinigunRevUpAnim = Humanoid:LoadAnimation(AnimTable.MinigunRevUpAnim)
  317. end
  318. if CommonVariables.SettingModules[i].MinigunRevDownAnimationID ~= nil then
  319. AnimTable.MinigunRevDownAnim = v:WaitForChild("MinigunRevDownAnim")
  320. AnimTable.MinigunRevDownAnim = Humanoid:LoadAnimation(AnimTable.MinigunRevDownAnim)
  321. end
  322. if CommonVariables.SettingModules[i].ChargingAnimationEnabled and CommonVariables.SettingModules[i].ChargingAnimationID ~= nil then
  323. AnimTable.ChargingAnim = v:WaitForChild("ChargingAnim")
  324. AnimTable.ChargingAnim = Humanoid:LoadAnimation(AnimTable.ChargingAnim)
  325. end
  326. if CommonVariables.SettingModules[i].SelectiveFireEnabled and CommonVariables.SettingModules[i].SwitchAnimationID ~= nil then
  327. AnimTable.SwitchAnim = v:WaitForChild("SwitchAnim")
  328. AnimTable.SwitchAnim = Humanoid:LoadAnimation(AnimTable.SwitchAnim)
  329. end
  330. if CommonVariables.SettingModules[i].BatteryEnabled and CommonVariables.SettingModules[i].OverheatAnimationID ~= nil then
  331. AnimTable.OverheatAnim = v:WaitForChild("OverheatAnim")
  332. AnimTable.OverheatAnim = Humanoid:LoadAnimation(AnimTable.OverheatAnim)
  333. end
  334. if CommonVariables.SettingModules[i].MeleeAttackEnabled and CommonVariables.SettingModules[i].MeleeAttackAnimationID ~= nil then
  335. AnimTable.MeleeAttackAnim = v:WaitForChild("MeleeAttackAnim")
  336. AnimTable.MeleeAttackAnim = Humanoid:LoadAnimation(AnimTable.MeleeAttackAnim)
  337. end
  338. if Module.AltFire and CommonVariables.SettingModules[i].AltAnimationID ~= nil then
  339. AnimTable.AltAnim = v:WaitForChild("AltAnim")
  340. AnimTable.AltAnim = Humanoid:LoadAnimation(AnimTable.AltAnim)
  341. end
  342. if CommonVariables.SettingModules[i].LaserBeamStartupAnimationID ~= nil then
  343. AnimTable.LaserBeamStartupAnim = v:WaitForChild("LaserBeamStartupAnim")
  344. AnimTable.LaserBeamStartupAnim = Humanoid:LoadAnimation(AnimTable.LaserBeamStartupAnim)
  345. end
  346. if CommonVariables.SettingModules[i].LaserBeamLoopAnimationID ~= nil then
  347. AnimTable.LaserBeamLoopAnim = v:WaitForChild("LaserBeamLoopAnim")
  348. AnimTable.LaserBeamLoopAnim = Humanoid:LoadAnimation(AnimTable.LaserBeamLoopAnim)
  349. end
  350. if CommonVariables.SettingModules[i].LaserBeamStopAnimationID ~= nil then
  351. AnimTable.LaserBeamStopAnim = v:WaitForChild("LaserBeamStopAnim")
  352. AnimTable.LaserBeamStopAnim = Humanoid:LoadAnimation(AnimTable.LaserBeamStopAnim)
  353. end
  354. table.insert(CommonVariables.Animations, AnimTable)
  355. end
  356.  
  357. local CurrentFireMode = 1
  358. local CurrentModule = CommonVariables.SettingModules[CurrentFireMode]
  359. local CurrentVariables = Variables[CurrentFireMode]
  360. local CurrentAnimTable = CommonVariables.Animations[CurrentFireMode]
  361. local CurrentCrosshair = GUI.Crosshair[CurrentFireMode]
  362.  
  363. for i, v in pairs(GUI.Crosshair:GetChildren()) do
  364. if v:IsA("CanvasGroup") then
  365. v.Visible = (tonumber(v.Name) == CurrentFireMode)
  366. end
  367. end
  368.  
  369. CommonVariables.ShootCounts = CurrentModule.ShootCounts
  370.  
  371. local UniversalTable
  372. if Module.UniversalAmmoEnabled then
  373. UniversalTable = {
  374. Ammo = ValueFolder.Ammo.Value;
  375. MaxAmmo = Module.Ammo;
  376. }
  377. else
  378. UniversalTable = CurrentVariables
  379. end
  380.  
  381. local HandleToFire = Tool:FindFirstChild(CurrentModule.Handles[1], true)
  382.  
  383. local CurrentAimFireAnim = #CurrentAnimTable.AimFireAnims > 0 and CurrentAnimTable.AimFireAnims[1][1] or nil
  384. local CurrentAimFireAnimationSpeed = #CurrentAnimTable.AimFireAnims > 0 and CurrentAnimTable.AimFireAnims[1][2] or nil
  385. local CurrentFireAnim = #CurrentAnimTable.FireAnims > 0 and CurrentAnimTable.FireAnims[1][1] or nil
  386. local CurrentFireAnimationSpeed = #CurrentAnimTable.FireAnims > 0 and CurrentAnimTable.FireAnims[1][2] or nil
  387.  
  388. local CurrentAimLastFireAnim = #CurrentAnimTable.AimLastFireAnims > 0 and CurrentAnimTable.AimLastFireAnims[1][1] or nil
  389. local CurrentAimLastFireAnimationSpeed = #CurrentAnimTable.AimLastFireAnims > 0 and CurrentAnimTable.AimLastFireAnims[1][2] or nil
  390. local CurrentLastFireAnim = #CurrentAnimTable.LastFireAnims > 0 and CurrentAnimTable.LastFireAnims[1][1] or nil
  391. local CurrentLastFireAnimationSpeed = #CurrentAnimTable.LastFireAnims > 0 and CurrentAnimTable.LastFireAnims[1][2] or nil
  392.  
  393. local CurrentShotgunPumpinAnim = #CurrentAnimTable.ShotgunPumpinAnims > 0 and CurrentAnimTable.ShotgunPumpinAnims[1][1] or nil
  394. local CurrentShotgunPumpinAnimationSpeed = #CurrentAnimTable.ShotgunPumpinAnims > 0 and CurrentAnimTable.ShotgunPumpinAnims[1][2] or nil
  395.  
  396. local BeamTable = {}
  397. local CrosshairPointAttachment = Instance.new("Attachment")
  398. CrosshairPointAttachment.Name = "CrosshairPointAttachment"
  399. local LaserBeamEffect = GunVisualEffects:FindFirstChild(CurrentModule.LaserBeamEffect)
  400. if LaserBeamEffect then
  401. for i, v in pairs(LaserBeamEffect.HitEffect:GetChildren()) do
  402. if v.ClassName == "ParticleEmitter" then
  403. local particle = v:Clone()
  404. particle.Enabled = true
  405. particle.Parent = CrosshairPointAttachment
  406. end
  407. end
  408. for i, v in pairs(LaserBeamEffect.LaserBeams:GetChildren()) do
  409. if v.ClassName == "Beam" then
  410. local beam = v:Clone()
  411. table.insert(BeamTable, beam)
  412. end
  413. end
  414. end
  415.  
  416. local function FindAnimationNameForKeyframe(AnimObject)
  417. if CurrentModule.AnimationKeyframes[AnimObject.Name] then
  418. table.insert(CommonVariables.Keyframes, {AnimObject, CurrentModule.AnimationKeyframes[AnimObject.Name]})
  419. end
  420. end
  421.  
  422. for _, a in pairs(CurrentAnimTable) do
  423. if typeof(a) == "table" then
  424. for _, a2 in pairs(a) do
  425. FindAnimationNameForKeyframe(a2[1])
  426. end
  427. else
  428. FindAnimationNameForKeyframe(a)
  429. end
  430. end
  431.  
  432. if Module.MagCartridge and not CurrentModule.BatteryEnabled and CurrentModule.AmmoPerMag ~= math.huge then
  433. for i = 1, CurrentModule.AmmoPerMag do
  434. local Bullet = GUI.MagCartridge.UIGridLayout.Template:Clone()
  435. Bullet.Name = i
  436. Bullet.LayoutOrder = i
  437. Bullet.Parent = GUI.MagCartridge
  438. end
  439. end
  440.  
  441. local Springs = {
  442. Scope = Spring.spring.new(Vector3.new(0, 200, 0));
  443. Knockback = Spring.spring.new(Vector3.new());
  444. CameraSpring = Spring.spring.new(Vector3.new());
  445. CrossScale = Spring.spring.new(0);
  446. CrossSpring = Spring.spring.new(0);
  447. }
  448.  
  449. Springs.Scope.s = CurrentModule.ScopeSwaySpeed
  450. Springs.Scope.d = CurrentModule.ScopeSwayDamper
  451.  
  452. Springs.Knockback.s = CurrentModule.ScopeKnockbackSpeed
  453. Springs.Knockback.d = CurrentModule.ScopeKnockbackDamper
  454.  
  455. Springs.CameraSpring.s = CurrentModule.RecoilSpeed
  456. Springs.CameraSpring.d = CurrentModule.RecoilDamper
  457.  
  458. Springs.CrossScale.s = 10
  459. Springs.CrossScale.d = 0.8
  460. Springs.CrossScale.t = 1
  461.  
  462. Springs.CrossSpring.s = 12
  463. Springs.CrossSpring.d = 0.65
  464.  
  465. local function SetCrossScale(Scale)
  466. Springs.CrossScale.t = Scale
  467. end
  468.  
  469. local function SetCrossSize(Size)
  470. Springs.CrossSpring.t = Size
  471. end
  472.  
  473. local function SetCrossSettings(Size, Speed, Damper)
  474. Springs.CrossSpring.t = Size
  475. Springs.CrossSpring.s = Speed
  476. Springs.CrossSpring.d = Damper
  477. end
  478.  
  479. local function Random2DDirection(Velocity, X, Y)
  480. return Vector2.new(X, Y) * (Velocity or 1)
  481. end
  482.  
  483. local function GetInstanceFromAncestor(Table)
  484. if Table[1] == "Tool" then
  485. return Tool:FindFirstChild(Table[2], true)
  486. end
  487. if Table[1] ~= "Character" then
  488. return
  489. end
  490. return Character:FindFirstChild(Table[2], true)
  491. end
  492.  
  493. local function AddressTableValue(ValueName, Setting)
  494. if CurrentModule.ChargedShotAdvanceEnabled and Setting.ChargeAlterTable then
  495. local AlterTable = Setting.ChargeAlterTable[ValueName]
  496. return AlterTable and ((CurrentVariables.ChargeLevel == 1 and AlterTable.Level1) or (CurrentVariables.ChargeLevel == 2 and AlterTable.Level2) or (CurrentVariables.ChargeLevel == 3 and AlterTable.Level3) or Setting[ValueName]) or Setting[ValueName]
  497. else
  498. return Setting[ValueName]
  499. end
  500. end
  501.  
  502. local function CanShoot()
  503. if CanShootConditions[CurrentFireMode] ~= nil then
  504. return CanShootConditions[CurrentFireMode](Tool, Humanoid, CurrentVariables.Heat, CurrentModule.MaxHeat, CurrentVariables.Mag, CurrentModule.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate)
  505. end
  506. return true
  507. end
  508.  
  509. local function PopulateHumanoids()
  510. for _, v in pairs(CollectionService:GetTagged("Humanoids")) do
  511. if v.Parent ~= Character and DamageModule.CanDamage(v.Parent, Character, CurrentModule.FriendlyFire) then
  512. table.insert(Humanoids, v)
  513. end
  514. end
  515. end
  516.  
  517. local function CastRay(Type, StartPos, Direction, Length, Blacklist, IgnoreWater, RealTargetHumanoid)
  518. debug.profilebegin("CastRay_(GunClient_"..Tool.Name..")")
  519. local Blacklist = CloneTable(Blacklist)
  520. local ShouldIgnoreHumanoid = CurrentModule.IgnoreHumanoids
  521. if Type ~= "Beam" then
  522. ShouldIgnoreHumanoid = false
  523. end
  524. local Iterations = 0
  525. local NewRay = Ray.new(StartPos, Direction * Length)
  526. local HitPart, HitPoint, HitNormal, HitMaterial = nil, StartPos + (Direction * Length), Vector3.new(0, 1, 0), Enum.Material.Air
  527. while Iterations < 20 do
  528. Iterations = Iterations + 1
  529. HitPart, HitPoint, HitNormal, HitMaterial = Workspace:FindPartOnRayWithIgnoreList(NewRay, Blacklist, false, IgnoreWater)
  530. if HitPart then
  531. local Target = HitPart:FindFirstAncestorOfClass("Model")
  532. local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
  533. local TargetTool = HitPart:FindFirstAncestorOfClass("Tool")
  534. if RealTargetHumanoid and TargetHumanoid then
  535. ShouldIgnoreHumanoid = (RealTargetHumanoid ~= TargetHumanoid)
  536. end
  537. if (--[[not HitPart.CanCollide
  538. or]] HitPart.Transparency > 0.75
  539. or HitPart.Name == "Handle"
  540. or (
  541. TargetHumanoid and (
  542. TargetHumanoid.Health <= 0
  543. or not DamageModule.CanDamage(Target, Character, CurrentModule.FriendlyFire)
  544. or ShouldIgnoreHumanoid
  545. )
  546. )
  547. or TargetTool) then
  548. table.insert(Blacklist, HitPart)
  549. else
  550. break
  551. end
  552. else
  553. break
  554. end
  555. end
  556. debug.profileend()
  557. return HitPart, HitPoint, HitNormal, HitMaterial
  558. end
  559.  
  560. local function Get3DPosition(Type, CurrentPosOnScreen)
  561. local InputRay = Camera:ScreenPointToRay(CurrentPosOnScreen.X, CurrentPosOnScreen.Y, 1000)
  562. local EndPos = InputRay.Origin + InputRay.Direction
  563. local HitPart, HitPoint, HitNormal, HitMaterial = CastRay(Type, Camera.CFrame.p, (EndPos - Camera.CFrame.p).Unit, 1000, IgnoreList, true)
  564. return HitPoint
  565. end
  566.  
  567. local function Get3DPosition2()
  568. local Type = CurrentModule.LaserBeam and "Beam" or "Tip"
  569. if Module.DirectShootingAt == "None" then
  570. return Get3DPosition(Type, GUI.Crosshair.Center.AbsolutePosition)
  571. else
  572. local FirePointObject = HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode)
  573. if FirePointObject ~= nil then
  574. local Direction = ((FirePointObject.WorldCFrame * CFrame.new(0, 0, -5000)).p - FirePointObject.WorldPosition).Unit
  575. local HitPart, HitPoint, HitNormal, HitMaterial = CastRay("Direct", FirePointObject.WorldPosition, Direction, 5000, IgnoreList, true)
  576. if Module.DirectShootingAt == "Both" then
  577. return HitPoint
  578. else
  579. if Module.DirectShootingAt == "FirstPerson" then
  580. if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 2 then
  581. return HitPoint
  582. else
  583. return Get3DPosition(Type, GUI.Crosshair.Center.AbsolutePosition)
  584. end
  585. elseif Module.DirectShootingAt == "ThirdPerson" then
  586. if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude > 2 then
  587. return HitPoint
  588. else
  589. return Get3DPosition(Type, GUI.Crosshair.Center.AbsolutePosition)
  590. end
  591. end
  592. end
  593. else
  594. return Get3DPosition(Type, GUI.Crosshair.Center.AbsolutePosition)
  595. end
  596. end
  597. end
  598.  
  599. local function CheckPartInScanner(part)
  600. if part and CommonVariables.Radar then
  601. local PartPos, OnScreen = Camera:WorldToScreenPoint(part.Position)
  602. if OnScreen then
  603. local FrameSize = CommonVariables.Radar.AbsoluteSize
  604. local FramePos = CommonVariables.Radar.AbsolutePosition
  605. return PartPos.X > FramePos.X and PartPos.Y > FramePos.Y and PartPos.X < FramePos.X + FrameSize.X and PartPos.Y < FramePos.Y + FrameSize.Y
  606. end
  607. end
  608. return false
  609. end
  610.  
  611. local function CheckForLockedTarget(Target, LockedOnTargets)
  612. local Found = false
  613. for _, v in pairs(LockedOnTargets) do
  614. if v and v.TargetEntity == Target then
  615. Found = true
  616. break
  617. end
  618. end
  619. return Found
  620. end
  621.  
  622. local function FindNearestEntity(LockedOnTargets)
  623. Humanoids = {}
  624. PopulateHumanoids()
  625. local RealDist = CurrentModule.LockOnDistance
  626. local MinOffset = nil
  627. local TargetModel = nil
  628. local TargetHumanoid = nil
  629. local TargetTorso = nil
  630. local AlreadyLocked = false
  631. local TargetCount = 0
  632. local LocketTargetCount = 0
  633. local SubHumanoids = {}
  634. if LockedOnTargets then
  635. for i, v in ipairs(Humanoids) do
  636. local torso = v.Parent:FindFirstChild("HumanoidRootPart") or v.Parent:FindFirstChild("Torso") or v.Parent:FindFirstChild("UpperTorso")
  637. local Dist = (Head.Position - torso.Position).Magnitude
  638. if v and torso and v.Health > 0 and CheckPartInScanner(torso) and Dist < (RealDist + (torso.Size.Magnitude / 2.5)) then
  639. if CheckForLockedTarget(v.Parent, LockedOnTargets) then
  640. LocketTargetCount += 1
  641. else
  642. TargetCount += 1
  643. end
  644. table.insert(SubHumanoids, v)
  645. end
  646. end
  647. end
  648. for i, v in ipairs(LockedOnTargets ~= nil and SubHumanoids or Humanoids) do
  649. local torso = v.Parent:FindFirstChild("HumanoidRootPart") or v.Parent:FindFirstChild("Torso") or v.Parent:FindFirstChild("UpperTorso")
  650. if v and torso then
  651. local Dist = (Head.Position - torso.Position).Magnitude
  652. local MousePos = Get3DPosition2()
  653. local MouseDirection = (MousePos - Head.Position).Unit
  654. local Offset = (((MouseDirection * Dist) + Head.Position) - torso.Position).Magnitude
  655. local CanFind = Dist < (RealDist + (torso.Size.Magnitude / 2.5)) and Offset < CurrentModule.LockOnRadius and (not MinOffset or Offset < MinOffset) and v.Health > 0
  656. if LockedOnTargets then
  657. CanFind = false
  658. local ShouldIgnore = false
  659. if CurrentModule.IgnoreLockedTargets and LocketTargetCount < #SubHumanoids then
  660. ShouldIgnore = CheckForLockedTarget(v.Parent, LockedOnTargets)
  661. end
  662. if CurrentModule.ContinueTrackingTargets and LocketTargetCount >= #SubHumanoids and #SubHumanoids < CurrentModule.MaximumTargets then
  663. ShouldIgnore = false
  664. end
  665. if v.Health > 0 and not ShouldIgnore and CheckPartInScanner(torso) then
  666. CanFind = Dist < (RealDist + (torso.Size.Magnitude / 2.5))
  667. end
  668. end
  669. local hit = not CurrentModule.LockOnThroughWall and CastRay("LockOn", Head.Position, (torso.CFrame.p - Head.Position).Unit, 999, IgnoreList, true, v) or nil
  670. local CanLock = true
  671. if not CurrentModule.LockOnThroughWall then
  672. CanLock = (hit and hit:IsDescendantOf(v.Parent))
  673. end
  674. if CanFind and CanLock and DamageModule.CanDamage(v.Parent, Character, CurrentModule.FriendlyFire) then
  675. TargetModel = v.Parent
  676. TargetHumanoid = v
  677. TargetTorso = torso
  678. AlreadyLocked = CheckForLockedTarget(v.Parent, LockedOnTargets)
  679. RealDist = Dist
  680. end
  681. end
  682. end
  683. table.clear(SubHumanoids)
  684. return TargetModel, TargetHumanoid, TargetTorso, AlreadyLocked
  685. end
  686.  
  687. function SetCustomGrip(Enabled)
  688. if Enabled then
  689. CommonVariables.GripId += 1
  690. local LastGripId = CommonVariables.GripId
  691. for i, v in pairs(Module.CustomGrips) do
  692. if LastGripId ~= CommonVariables.GripId then
  693. break
  694. end
  695. local Part0 = GetInstanceFromAncestor(v.CustomGripPart0)
  696. local Part1 = GetInstanceFromAncestor(v.CustomGripPart1)
  697. if not Part0 or not Part1 then
  698. continue
  699. end
  700. local Motor6DInstance = Instance.new("Motor6D")
  701. Motor6DInstance.Name = v.CustomGripName
  702. Motor6DInstance.Part0 = Part0
  703. Motor6DInstance.Part1 = Part1
  704. Motor6DInstance:SetAttribute("Id", i)
  705. if Part1.Name == "Handle" and Part1.Parent == Tool then
  706. if not CommonVariables.DefaultC0 or not CommonVariables.DefaultC1 then
  707. repeat task.wait() if LastGripId ~= CommonVariables.GripId then break end until RightArm:FindFirstChild("RightGrip")
  708. if LastGripId == CommonVariables.GripId then
  709. local RightGrip = RightArm:FindFirstChild("RightGrip")
  710. if RightGrip then
  711. CommonVariables.DefaultC0 = RightGrip.C0
  712. CommonVariables.DefaultC1 = RightGrip.C1
  713. RightGrip.Enabled = false
  714. RightGrip:Destroy()
  715. end
  716. end
  717. end
  718. if CommonVariables.DefaultC0 and CommonVariables.DefaultC1 then
  719. if v.AlignC0AndC1FromDefaultGrip then
  720. Motor6DInstance.C0 = CommonVariables.DefaultC0
  721. Motor6DInstance.C1 = CommonVariables.DefaultC1
  722. end
  723. if v.CustomGripCFrame then
  724. Motor6DInstance.C0 *= v.CustomGripC0
  725. Motor6DInstance.C1 *= v.CustomGripC1
  726. end
  727. Motor6DInstance.Parent = Part0
  728. table.insert(CommonVariables.Motor6DInstances, Motor6DInstance)
  729. end
  730. else
  731. if v.AlignC0AndC1FromDefaultGrip and CommonVariables.DefaultC0 and CommonVariables.DefaultC1 then
  732. Motor6DInstance.C0 = CommonVariables.DefaultC0
  733. Motor6DInstance.C1 = CommonVariables.DefaultC1
  734. end
  735. if v.CustomGripCFrame then
  736. Motor6DInstance.C0 *= v.CustomGripC0
  737. Motor6DInstance.C1 *= v.CustomGripC1
  738. end
  739. Motor6DInstance.Parent = Part0
  740. table.insert(CommonVariables.Motor6DInstances, Motor6DInstance)
  741. end
  742. end
  743. else
  744. CommonVariables.GripId += 1
  745. for _, v in pairs(CommonVariables.Motor6DInstances) do
  746. if v then
  747. v:Destroy()
  748. end
  749. end
  750. table.clear(CommonVariables.Motor6DInstances)
  751. CommonVariables.DefaultC0 = nil
  752. CommonVariables.DefaultC1 = nil
  753. end
  754. end
  755.  
  756. function UpdateGUI()
  757. if CurrentModule.AmmoPerMag ~= math.huge and CurrentModule.MaxHeat ~= math.huge then
  758. GUI.Frame.Counter.Visible = true
  759. end
  760.  
  761. GUI.Frame.Counter.Mag.Fill:TweenSize(UDim2.new(CurrentVariables.Mag / CurrentModule.AmmoPerMag, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true)
  762. GUI.Frame.Counter.Ammo.Fill:TweenSize(UDim2.new(UniversalTable.Ammo / UniversalTable.MaxAmmo, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true)
  763. GUI.Frame.Counter.Heat.Fill:TweenSize(UDim2.new(CurrentVariables.Heat / CurrentModule.MaxHeat, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true)
  764. GUI.Frame.Counter.Mag.Current.Text = CurrentVariables.Mag
  765. GUI.Frame.Counter.Mag.Max.Text = CurrentModule.AmmoPerMag
  766. GUI.Frame.Counter.Ammo.Current.Text = UniversalTable.Ammo
  767. GUI.Frame.Counter.Ammo.Max.Text = UniversalTable.MaxAmmo
  768. GUI.Frame.Counter.Heat.Current.Text = CurrentVariables.Heat
  769. GUI.Frame.Counter.Heat.Max.Text = CurrentModule.MaxHeat
  770.  
  771. GUI.Frame.FireMode.Alternative.Visible = (Module.AltFire and CurrentModule.AltName ~= "")
  772. GUI.Frame.FireMode.Alternative.Text = CurrentModule.AltName
  773. GUI.Frame.FireMode.Selective.Visible = (CurrentModule.SelectiveFireEnabled and CurrentModule.FireModeTexts[CurrentVariables.FireMode] ~= "")
  774. GUI.Frame.FireMode.Selective.Text = CurrentModule.FireModeTexts[CurrentVariables.FireMode]
  775.  
  776. GUI.Frame.Counter.Mag.Current.Visible = not CommonVariables.Reloading
  777. GUI.Frame.Counter.Mag.Max.Visible = not CommonVariables.Reloading
  778. GUI.Frame.Counter.Mag.Frame.Visible = not CommonVariables.Reloading
  779. GUI.Frame.Counter.Mag.Reloading.Visible = CommonVariables.Reloading
  780.  
  781. GUI.Frame.Counter.Ammo.Current.Visible = not (UniversalTable.Ammo <= 0)
  782. GUI.Frame.Counter.Ammo.Max.Visible = not (UniversalTable.Ammo <= 0)
  783. GUI.Frame.Counter.Ammo.Frame.Visible = not (UniversalTable.Ammo <= 0)
  784. GUI.Frame.Counter.Ammo.NoMoreAmmo.Visible = (UniversalTable.Ammo <= 0)
  785.  
  786. GUI.Frame.Counter.Heat.Visible = CurrentModule.BatteryEnabled
  787. GUI.Frame.Counter.Heat.Current.Visible = not CommonVariables.Overheated
  788. GUI.Frame.Counter.Heat.Max.Visible = not CommonVariables.Overheated
  789. GUI.Frame.Counter.Heat.Frame.Visible = not CommonVariables.Overheated
  790. GUI.Frame.Counter.Heat.Overheated.Visible = CommonVariables.Overheated
  791.  
  792. GUI.ChargeBar.Visible = (CurrentModule.ChargedShotAdvanceEnabled or (CurrentModule.HoldAndReleaseEnabled and not CurrentModule.LockOnScan))
  793. GUI.ChargeBar.Level1.Visible = not CurrentModule.HoldAndReleaseEnabled and CurrentVariables.ChargeLevelCap > 1
  794. GUI.ChargeBar.Level2.Visible = not CurrentModule.HoldAndReleaseEnabled and CurrentVariables.ChargeLevelCap > 2
  795. local ChargeTime = CurrentModule.AdvancedChargingTime
  796. if CurrentVariables.ChargeLevelCap == 1 then
  797. ChargeTime = CurrentModule.Level1ChargingTime
  798. elseif CurrentVariables.ChargeLevelCap == 2 then
  799. ChargeTime = CurrentModule.Level2ChargingTime
  800. end
  801. GUI.ChargeBar.Level1.Position = UDim2.new(CurrentModule.Level1ChargingTime / ChargeTime, 0, 0.5, 0)
  802. GUI.ChargeBar.Level2.Position = UDim2.new(CurrentModule.Level2ChargingTime / ChargeTime, 0, 0.5, 0)
  803. GUI.ChargeBar.Position = Module.MagCartridge and UDim2.new(1, -260, 1, -70) or UDim2.new(1, -260, 1, -35)
  804.  
  805. GUI.MagCartridge.Visible = Module.MagCartridge
  806.  
  807. GUI.Frame.Counter.Mag.Visible = not CurrentModule.BatteryEnabled
  808. GUI.Frame.Counter.Ammo.Visible = (Module.UniversalAmmoEnabled or CurrentModule.LimitedAmmoEnabled)
  809. GUI.Frame.Counter.Heat.Visible = CurrentModule.BatteryEnabled
  810. GUI.Frame.Counter.Size = (Module.UniversalAmmoEnabled or CurrentModule.LimitedAmmoEnabled) and UDim2.new(1, 0, 0, 100) or UDim2.new(1, 0, 0, 55)
  811. GUI.Frame.Position = (CurrentModule.ChargedShotAdvanceEnabled or (CurrentModule.HoldAndReleaseEnabled and not CurrentModule.LockOnScan)) and (Module.MagCartridge and UDim2.new(1, -260, 1, -190) or UDim2.new(1, -260, 1, -150)) or (Module.MagCartridge and UDim2.new(1, -260, 1, -150) or UDim2.new(1, -260, 1, -110))
  812.  
  813. --For mobile version
  814. GUI.MobileButtons.Visible = UserInputService.TouchEnabled
  815. MobileButtons.SubFireButton.Visible = UserInputService.TouchEnabled
  816. MobileButtons.AimButton.Visible = CurrentModule.ADSEnabled
  817. MobileButtons.HoldDownButton.Visible = CurrentModule.HoldDownEnabled
  818. MobileButtons.InspectButton.Visible = CurrentModule.InspectAnimationEnabled
  819. MobileButtons.SwitchButton.Visible = CurrentModule.SelectiveFireEnabled
  820. MobileButtons.ReloadButton.Visible = not CurrentModule.BatteryEnabled
  821. MobileButtons.MeleeButton.Visible = CurrentModule.MeleeAttackEnabled
  822. MobileButtons.AltButton.Visible = Module.AltFire
  823. end
  824.  
  825. function Render(dt)
  826. --Scope (OLD)
  827.  
  828. --[[if CommonVariables.Scoping and UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then --For pc version
  829. GUI.Scope.Size = UDim2.new(Math.Lerp(GUI.Scope.Size.X.Scale, 1.2, math.min(dt * 5, 1)), 36, Math.Lerp(GUI.Scope.Size.Y.Scale, 1.2, math.min(dt * 5, 1)), 36)
  830. GUI.Scope.Position = UDim2.new(0, Mouse.X - GUI.Scope.AbsoluteSize.X / 2, 0, Mouse.Y - GUI.Scope.AbsoluteSize.Y / 2)
  831. elseif CommonVariables.Scoping and UserInputService.TouchEnabled and not UserInputService.MouseEnabled and not UserInputService.KeyboardEnabled then --For mobile version, but in first-person view
  832. GUI.Scope.Size = UDim2.new(Math.Lerp(GUI.Scope.Size.X.Scale, 1.2, math.min(dt * 5, 1)), 36, Math.Lerp(GUI.Scope.Size.Y.Scale, 1.2, math.min(dt * 5, 1)), 36)
  833. GUI.Scope.Position = UDim2.new(0, GUI.Crosshair.AbsolutePosition.X - GUI.Scope.AbsoluteSize.X / 2, 0, GUI.Crosshair.AbsolutePosition.Y - GUI.Scope.AbsoluteSize.Y / 2)
  834. else
  835. GUI.Scope.Size = UDim2.new(0.6, 36, 0.6, 36)
  836. GUI.Scope.Position = UDim2.new(0, 0, 0, 0)
  837. end]]
  838.  
  839. --Crosshair and scope
  840.  
  841. Springs.Knockback.t = Springs.Knockback.t:Lerp(Vector3.new(), 0.2)
  842.  
  843. local function UpdateCrosshair()
  844. if UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then --For pc version
  845. GUI.Crosshair.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
  846. elseif UserInputService.TouchEnabled and not UserInputService.MouseEnabled and not UserInputService.KeyboardEnabled and (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude > 2 then --For mobile version, but in third-person view
  847. GUI.Crosshair.Position = UDim2.new(0.5, 0, 0.4, -50)
  848. elseif UserInputService.TouchEnabled and not UserInputService.MouseEnabled and not UserInputService.KeyboardEnabled and (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 2 then --For mobile version, but in first-person view
  849. GUI.Crosshair.Position = UDim2.new(0.5, -1, 0.5, -19)
  850. end
  851. end
  852.  
  853. local Delta = UserInputService:GetMouseDelta() / CurrentModule.ScopeSensitivity
  854. local Offset = GUI.Scope.AbsoluteSize.X * 0.5
  855.  
  856. if CommonVariables.Scoping and UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then --For pc version
  857. GUI.Scope.Position = UDim2.new(0, Springs.Scope.p.X + (Springs.Knockback.p.Y * 1000), 0, Springs.Scope.p.Y + (Springs.Knockback.p.X * 200))
  858. Springs.Scope.t = Vector3.new(Mouse.X - Offset - Delta.X, Mouse.Y - Offset - Delta.Y, 0)
  859. elseif CommonVariables.Scoping and UserInputService.TouchEnabled and not UserInputService.MouseEnabled and not UserInputService.KeyboardEnabled then --For mobile version, but in first-person view
  860. GUI.Scope.Position = UDim2.new(0, Springs.Scope.p.X + (Springs.Knockback.p.Y * 1000), 0, Springs.Scope.p.Y + (Springs.Knockback.p.X * 200))
  861. Springs.Scope.t = Vector3.new(GUI.Crosshair.Center.AbsolutePosition.X - Offset - Delta.X, GUI.Crosshair.Center.AbsolutePosition.Y - Offset - Delta.Y, 0)
  862. end
  863.  
  864. GUI.Scope.Visible = CommonVariables.Scoping
  865. if not CommonVariables.Scoping then
  866. --CurrentCrosshair.Visible = true
  867. Springs.Scope.t = Vector3.new(600, 200, 0)
  868. else
  869. --CurrentCrosshair.Visible = false
  870. end
  871.  
  872. if Module.DirectShootingAt == "None" then
  873. UpdateCrosshair()
  874. else
  875. local FirePointObject = HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode)
  876. if FirePointObject ~= nil then
  877. local Position, _ = Camera:WorldToScreenPoint((FirePointObject.WorldCFrame * CFrame.new(0, 0, -5000)).p)
  878. if Module.DirectShootingAt == "Both" then
  879. GUI.Crosshair.Position = UDim2.fromOffset(Position.X, Position.Y)
  880. else
  881. if Module.DirectShootingAt == "FirstPerson" then
  882. if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 2 then
  883. GUI.Crosshair.Position = UDim2.fromOffset(Position.X, Position.Y)
  884. else
  885. UpdateCrosshair()
  886. end
  887. elseif Module.DirectShootingAt == "ThirdPerson" then
  888. if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude > 2 then
  889. GUI.Crosshair.Position = UDim2.fromOffset(Position.X, Position.Y)
  890. else
  891. UpdateCrosshair()
  892. end
  893. end
  894. end
  895. else
  896. UpdateCrosshair()
  897. end
  898. end
  899.  
  900. local Size = Springs.CrossSpring.p * 4 * Springs.CrossScale.p
  901. GUI.Crosshair.Size = UDim2.new(0, Size, 0, Size)
  902.  
  903. --Radar and target marker
  904.  
  905. if CommonVariables.Radar then
  906. CommonVariables.Radar.Position = CurrentModule.StayInCenter and UDim2.new(0.5, 0, 0.5, 0) or UDim2.new(0, GUI.Crosshair.Center.AbsolutePosition.X, 0, GUI.Crosshair.Center.AbsolutePosition.Y)
  907. end
  908.  
  909. if AddressTableValue("Homing", CurrentModule) and CurrentModule.LockOnOnHovering then
  910. local TargetEntity, TargetHumanoid, TargetTorso = FindNearestEntity()
  911. if TargetEntity and TargetHumanoid and TargetTorso then
  912. LockedEntity = TargetEntity
  913. TargetMarker.Parent = GUI
  914. TargetMarker.Adornee = TargetTorso
  915. TargetMarker.Enabled = true
  916. else
  917. LockedEntity = nil
  918. TargetMarker.Enabled = false
  919. TargetMarker.Parent = nil
  920. TargetMarker.Adornee = nil
  921. end
  922. end
  923.  
  924. --Motion beam
  925.  
  926. if CurrentModule.ProjectileMotion then
  927. if CommonVariables.Beam and CommonVariables.Attach0 and CommonVariables.Attach1 then
  928. local Position = Get3DPosition2()
  929. local cframe = CFrame.new(HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode).WorldPosition, Position)
  930. local direction = cframe.LookVector
  931.  
  932. if direction then
  933. ProjectileMotion.UpdateProjectilePath(CommonVariables.Beam, CommonVariables.Attach0, CommonVariables.Attach1, HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode).WorldPosition, direction * AddressTableValue("BulletSpeed", CurrentModule), 3, AddressTableValue("Acceleration", CurrentModule))
  934. end
  935. end
  936. end
  937.  
  938. --Cooldown
  939.  
  940. if CurrentModule.BatteryEnabled then
  941. CurrentVariables.ElapsedCooldownTime = CurrentVariables.ElapsedCooldownTime + dt
  942. if CurrentVariables.ElapsedCooldownTime >= CurrentModule.CooldownTime then
  943. CurrentVariables.ElapsedCooldownTime = 0
  944. if not CommonVariables.Down and not CommonVariables.Overheated and CommonVariables.CanBeCooledDown and CurrentVariables.Heat > 0 then
  945. CurrentVariables.Heat = math.clamp(CurrentVariables.Heat - CurrentModule.CooldownRate, 0, CurrentModule.MaxHeat)
  946. UpdateGUI()
  947. end
  948. end
  949. end
  950.  
  951. --Camera
  952.  
  953. Camera.CoordinateFrame = Camera.CoordinateFrame * CFrame.Angles(Springs.CameraSpring.p.X * (dt * 60), Springs.CameraSpring.p.Y * (dt * 60), Springs.CameraSpring.p.Z * (dt * 60))
  954.  
  955. if Module.ThirdPersonADS then
  956. if CommonVariables.AimDown and ((Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1) then
  957. Player.CameraMode = Enum.CameraMode.LockFirstPerson
  958. end
  959. end
  960.  
  961. --Smoke trail
  962.  
  963. CommonVariables.ElapsedTime = CommonVariables.ElapsedTime + dt
  964. if CommonVariables.ElapsedTime >= 1 then
  965. CommonVariables.ElapsedTime = 0
  966. CommonVariables.CurrentRate = CommonVariables.CurrentRate - CommonVariables.LastRate
  967. CommonVariables.LastRate = CommonVariables.CurrentRate
  968. end
  969.  
  970. --2D Ammo counter
  971.  
  972. local Drag = Module.Drag ^ dt
  973. for casing, data in pairs(CommonVariables.Casings) do
  974. if casing.Parent then
  975. data.Vel = (data.Vel * Drag) + Module.Gravity * dt
  976. data.Pos = data.Pos + data.Vel * dt
  977. data.RotVel = data.RotVel * Drag
  978. data.Rot = data.Rot + data.RotVel * dt
  979. casing.Position = UDim2.new(0, data.Pos.X, 0, data.Pos.Y)
  980. casing.Rotation = data.Rot
  981. if casing.AbsolutePosition.Y > Killzone then
  982. casing:Destroy()
  983. CommonVariables.CasingCount = CommonVariables.CasingCount - 1
  984. CommonVariables.Casings[casing] = nil
  985. end
  986. else
  987. CommonVariables.CasingCount = CommonVariables.CasingCount - 1
  988. CommonVariables.Casings[casing] = nil
  989. end
  990. end
  991.  
  992. --Lock-on scanner
  993.  
  994. if CurrentModule.HoldAndReleaseEnabled and CurrentModule.LockOnScan then
  995. CurrentModule.OnScannerRender(CommonVariables.Radar, dt)
  996. end
  997.  
  998. --Animations
  999.  
  1000. if CurrentAnimTable.ChargingAnim and CurrentAnimTable.AimChargingAnim then
  1001. CurrentAnimTable.ChargingAnim:AdjustWeight(CommonVariables.AimDown and 0 or 1)
  1002. CurrentAnimTable.AimChargingAnim:AdjustWeight(CommonVariables.AimDown and 1 or 0)
  1003. end
  1004. end
  1005.  
  1006. function SetAnimationTrack(AnimationName, Action, Speed, FadeTime, WhenToSet)
  1007. local AnimationTrack = CurrentAnimTable[AnimationName]
  1008. if AnimationName == "AimFireAnim" then
  1009. AnimationTrack = CurrentAimFireAnim
  1010. elseif AnimationName == "FireAnim" then
  1011. AnimationTrack = CurrentFireAnim
  1012. elseif AnimationName == "AimLastFireAnim" then
  1013. AnimationTrack = CurrentAimLastFireAnim
  1014. elseif AnimationName == "LastFireAnim" then
  1015. AnimationTrack = CurrentLastFireAnim
  1016. elseif AnimationName == "ShotgunPumpinAnim" then
  1017. AnimationTrack = CurrentShotgunPumpinAnim
  1018. elseif AnimationName == "InspectAnim" then
  1019. AnimationTrack = (CurrentVariables.Mag <= 0) and CurrentAnimTable.EmptyInspectAnim or CurrentAnimTable.InspectAnim
  1020. end
  1021. if AnimationTrack then
  1022. local CanSet = true
  1023. if WhenToSet then
  1024. if WhenToSet == "IsPlaying" then
  1025. CanSet = AnimationTrack.IsPlaying
  1026. else
  1027. CanSet = not AnimationTrack.IsPlaying
  1028. end
  1029. end
  1030. if CanSet then
  1031. if Action == "Play" then
  1032. AnimationTrack:Play(FadeTime, nil, Speed)
  1033. else
  1034. AnimationTrack:Stop(FadeTime)
  1035. end
  1036. end
  1037. end
  1038. end
  1039.  
  1040. function SetFireSoundLoopEnabled(Id, Enabled)
  1041. if CurrentModule.ShouldLoop then
  1042. local FireSound = HandleToFire[CurrentFireMode]:FindFirstChild(AddressTableValue("FireSound", CurrentModule))
  1043. if FireSound and FireSound:IsA("Sound") then
  1044. gunEvent:Fire("PlayAudio",
  1045. {
  1046. Instance = FireSound,
  1047. Origin = HandleToFire:FindFirstChild("GunMuzzlePoint"..CurrentFireMode),
  1048. Echo = CurrentModule.EchoEffect,
  1049. Silenced = CurrentModule.SilenceEffect,
  1050. LoopData = {
  1051. Enabled = Enabled,
  1052. Id = Id
  1053. }
  1054. }, nil, true)
  1055. end
  1056. end
  1057. end
  1058.  
  1059. function VisibleMuzz(MuzzlePointObject, Enabled)
  1060. for i, v in pairs(MuzzlePointObject:GetChildren()) do
  1061. if v.ClassName == "ParticleEmitter" then
  1062. if v:FindFirstChild("EmitCount") then
  1063. if Enabled then
  1064. Thread:Delay(0.01, function()
  1065. v:Emit(v.EmitCount.Value)
  1066. end)
  1067. end
  1068. else
  1069. v.Enabled = Enabled
  1070. end
  1071. end
  1072. end
  1073. end
  1074.  
  1075. function MarkHit(ClientModule, IsHeadshot)
  1076. if ClientModule.HitmarkerEnabled then
  1077. if IsHeadshot then
  1078. GUI.Crosshair.Hitmarker.ImageColor3 = ClientModule.HitmarkerColorHS
  1079. GUI.Crosshair.Hitmarker.ImageTransparency = 0
  1080. TweenService:Create(GUI.Crosshair.Hitmarker, TweenInfo.new(ClientModule.HitmarkerFadeTimeHS, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {ImageTransparency = 1}):Play()
  1081. else
  1082. GUI.Crosshair.Hitmarker.ImageColor3 = ClientModule.HitmarkerColor
  1083. GUI.Crosshair.Hitmarker.ImageTransparency = 0
  1084. TweenService:Create(GUI.Crosshair.Hitmarker, TweenInfo.new(ClientModule.HitmarkerFadeTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {ImageTransparency = 1}):Play()
  1085. end
  1086. local MarkerSound = GUI.Crosshair.MarkerSound:Clone()
  1087. MarkerSound.Name = "MarkerSoundClone"
  1088. MarkerSound.SoundId = "rbxassetid://"..ClientModule.HitmarkerSoundIDs[math.random(1, #ClientModule.HitmarkerSoundIDs)]
  1089. MarkerSound.PlaybackSpeed = IsHeadshot and ClientModule.HitmarkerSoundPitchHS or ClientModule.HitmarkerSoundPitch
  1090. MarkerSound.Parent = GUI.Crosshair
  1091. MarkerSound:Play()
  1092. Debris:AddItem(MarkerSound, 1)
  1093. end
  1094. end
  1095.  
  1096. function EjectShell(ShootingHandle, TempModule)
  1097. if AddressTableValue("BulletShellEnabled", TempModule) then
  1098. if AddressTableValue("BulletShellParticles", TempModule) then
  1099. local ShellEjectParticlePoint = ShootingHandle:FindFirstChild("ShellEjectParticlePoint"..CurrentFireMode)
  1100. local ShellEjectEffect = GunVisualEffects:FindFirstChild(AddressTableValue("ShellEjectEffect", TempModule))
  1101. if ShellEjectParticlePoint and ShellEjectEffect then
  1102. for i, v in pairs(ShellEjectEffect:GetChildren()) do
  1103. if v.ClassName == "ParticleEmitter" then
  1104. local Count = 1
  1105. local Particle = v:Clone()
  1106. Particle.Parent = ShellEjectParticlePoint
  1107. if Particle:FindFirstChild("EmitCount") then
  1108. Count = Particle.EmitCount.Value
  1109. end
  1110. Thread:Delay(0.01, function()
  1111. Particle:Emit(Count)
  1112. Debris:AddItem(Particle, Particle.Lifetime.Max)
  1113. end)
  1114. end
  1115. end
  1116. end
  1117. end
  1118. local RadomizeRotVelocity = AddressTableValue("RadomizeRotVelocity", TempModule)
  1119. local EjectPoint = ShootingHandle:FindFirstChild("ShellEjectPoint"..CurrentFireMode)
  1120. if not EjectPoint then
  1121. return
  1122. end
  1123. local Shell = Miscs.BulletShells[AddressTableValue("BulletShellType", TempModule)]:Clone()
  1124. Shell.CFrame = EjectPoint.WorldCFrame
  1125. Shell.CanCollide = AddressTableValue("AllowCollide", TempModule)
  1126. Shell.Velocity = EjectPoint.WorldCFrame.LookVector * AddressTableValue("BulletShellVelocity", TempModule)
  1127. Shell.RotVelocity = (RadomizeRotVelocity and EjectPoint.WorldCFrame.XVector or EjectPoint.WorldCFrame.LookVector) * AddressTableValue("BulletShellRotVelocity", TempModule)
  1128. Shell.Parent = Camera
  1129. if AddressTableValue("BulletShellHitSoundEnabled", TempModule) then
  1130. local BulletShellHitSoundIDs = AddressTableValue("BulletShellHitSoundIDs", TempModule)
  1131. local BulletShellHitSoundVolume = AddressTableValue("BulletShellHitSoundVolume", TempModule)
  1132. local BulletShellHitSoundPitchMin = AddressTableValue("BulletShellHitSoundPitchMin", TempModule)
  1133. local BulletShellHitSoundPitchMax = AddressTableValue("BulletShellHitSoundPitchMax", TempModule)
  1134. local TouchedConnection = nil
  1135. TouchedConnection = Shell.Touched:Connect(function(Hit)
  1136. if not Hit:IsDescendantOf(Character) then
  1137. local Sound = Instance.new("Sound")
  1138. Sound.SoundId = "rbxassetid://"..BulletShellHitSoundIDs[math.random(1, #BulletShellHitSoundIDs)]
  1139. Sound.PlaybackSpeed = Random.new():NextNumber(BulletShellHitSoundPitchMin, BulletShellHitSoundPitchMax)
  1140. Sound.Volume = BulletShellHitSoundVolume
  1141. Sound.Parent = Shell
  1142. Sound:Play()
  1143. TouchedConnection:Disconnect()
  1144. TouchedConnection = nil
  1145. end
  1146. end)
  1147. end
  1148. Debris:AddItem(Shell, AddressTableValue("DisappearTime", TempModule))
  1149. end
  1150. end
  1151.  
  1152. function CreateCasing(ObjRot, Pos, Size, Vel, Type, Shockwave)
  1153. local MaxedOut = CommonVariables.CasingCount >= Module.MaxCount
  1154. if MaxedOut and Module.RemoveOldAtMax and math.random() then
  1155. --This is the best method I can figure for removing a random item from a dictionary of known length
  1156. local RemoveCoutndown = math.random(1, Module.MaxCount)
  1157. for casing, _ in pairs(CommonVariables.Casings) do
  1158. RemoveCoutndown = RemoveCoutndown - 1
  1159. if RemoveCoutndown <= 0 then
  1160. casing:Destroy()
  1161. CommonVariables.CasingCount = CommonVariables.CasingCount - 1
  1162. CommonVariables.Casings[casing] = nil
  1163. MaxedOut = CommonVariables.CasingCount >= Module.MaxCount
  1164. break
  1165. end
  1166. end
  1167. end
  1168. if not MaxedOut then
  1169. CommonVariables.CasingCount = CommonVariables.CasingCount + 1
  1170. local Rot = ObjRot --math.random() * 360
  1171. local XCenter = Pos.X + (Size.X / 2)
  1172. local YCenter = Pos.Y + (Size.Y / 2)
  1173. local Data = {
  1174. RotVel = (math.random() * 2 - 1) * Module.MaxRotationSpeed,
  1175. Rot = Rot,
  1176. Pos = (Pos and Vector2.new(XCenter, YCenter) or Vector2.new(0, 0)) + TopbarOffset,
  1177. Vel = Vel or Vector2.new(0, 0),
  1178. }
  1179. local Casing = GUI.MagCartridge.UIGridLayout.Shell
  1180. if Type == "Bullet" then
  1181. Casing = GUI.MagCartridge.UIGridLayout.Template
  1182. end
  1183. local Clone = Casing:Clone()
  1184. Clone.Rotation = Rot
  1185. CommonVariables.Casings[Clone] = Data
  1186. Clone.Parent = GUI
  1187. if Shockwave then
  1188. Thread:Spawn(function()
  1189. local ShockwaveClone = GUI.MagCartridge.UIGridLayout.Shockwave:Clone()
  1190. local Degree = math.rad(math.random(360))
  1191. ShockwaveClone.Position = UDim2.new(0, XCenter, 0, YCenter)
  1192. ShockwaveClone.Rotation = math.deg(Degree)
  1193. ShockwaveClone.Parent = GUI
  1194. local Tween = TweenService:Create(ShockwaveClone, TweenInfo.new(0.25, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = UDim2.new(0, 50, 0, 50), ImageTransparency = 1})
  1195. Tween:Play()
  1196. Tween.Completed:Wait()
  1197. ShockwaveClone:Destroy()
  1198. end)
  1199. end
  1200. end
  1201. end
  1202.  
  1203. function Fire(ShootingHandle, MousePosition, FireDirections, TempModule, ModNames, Target, FirstShot)
  1204. --This code block manages one-time, looped or last-shot fire animations
  1205. if (CurrentVariables.Mag - AddressTableValue("AmmoCost", TempModule)) <= 0 then
  1206. if CommonVariables.AimDown then
  1207. if CurrentAimLastFireAnim then
  1208. if CurrentAimFireAnim and CurrentAimFireAnim.Looped then
  1209. SetAnimationTrack("AimFireAnim", "Stop", nil, 0)
  1210. end
  1211. SetAnimationTrack("AimLastFireAnim", "Play", CurrentAimLastFireAnimationSpeed, 0.05)
  1212. else
  1213. if CurrentAimFireAnim then
  1214. if CurrentFireAnim and CurrentFireAnim.Looped then
  1215. SetAnimationTrack("FireAnim", "Stop", nil, 0)
  1216. end
  1217. SetAnimationTrack("AimFireAnim", "Play", CurrentAimFireAnimationSpeed, 0.05, CurrentAimFireAnim.Looped and "IsNotPlaying" or nil)
  1218. else
  1219. if CurrentLastFireAnim then
  1220. if CurrentFireAnim and CurrentFireAnim.Looped then
  1221. SetAnimationTrack("FireAnim", "Stop", nil, 0)
  1222. end
  1223. SetAnimationTrack("LastFireAnim", "Play", CurrentLastFireAnimationSpeed, 0.05)
  1224. else
  1225. SetAnimationTrack("FireAnim", "Play", CurrentFireAnimationSpeed, 0.05, (CurrentFireAnim and CurrentFireAnim.Looped) and "IsNotPlaying" or nil)
  1226. end
  1227. end
  1228. end
  1229. else
  1230. if CurrentAimFireAnim and CurrentAimFireAnim.Looped then
  1231. SetAnimationTrack("AimFireAnim", "Stop", nil, 0)
  1232. end
  1233. if CurrentLastFireAnim then
  1234. if CurrentFireAnim and CurrentFireAnim.Looped then
  1235. SetAnimationTrack("FireAnim", "Stop", nil, 0)
  1236. end
  1237. SetAnimationTrack("LastFireAnim", "Play", CurrentLastFireAnimationSpeed, 0.05)
  1238. else
  1239. SetAnimationTrack("FireAnim", "Play", CurrentFireAnimationSpeed, 0.05, (CurrentFireAnim and CurrentFireAnim.Looped) and "IsNotPlaying" or nil)
  1240. end
  1241. end
  1242. else
  1243. if CurrentAimFireAnim and CommonVariables.AimDown then
  1244. if CurrentFireAnim and CurrentFireAnim.Looped then
  1245. SetAnimationTrack("FireAnim", "Stop", nil, 0)
  1246. end
  1247. SetAnimationTrack("AimFireAnim", "Play", CurrentAimFireAnimationSpeed, 0.05, CurrentAimFireAnim.Looped and "IsNotPlaying" or nil)
  1248. else
  1249. if CurrentAimFireAnim and CurrentAimFireAnim.Looped then
  1250. SetAnimationTrack("AimFireAnim", "Stop", nil, 0)
  1251. end
  1252. SetAnimationTrack("FireAnim", "Play", CurrentFireAnimationSpeed, 0.05, (CurrentFireAnim and CurrentFireAnim.Looped) and "IsNotPlaying" or nil)
  1253. end
  1254. end
  1255. --
  1256. SetAnimationTrack("MinigunRevUpAnim", "Stop")
  1257. local CanPlay = true
  1258. if TempModule.LockOnScan and TempModule.InstaBurst then
  1259. CanPlay = FirstShot
  1260. end
  1261. local FireSound = ShootingHandle[CurrentFireMode]:FindFirstChild(AddressTableValue("FireSound", TempModule))
  1262. if CanPlay and FireSound and not TempModule.ShouldLoop then
  1263. local Track = FireSound
  1264. if FireSound:IsA("Folder") then
  1265. local Tracks = FireSound:GetChildren()
  1266. local Chosen = math.random(1, #Tracks)
  1267. Track = Tracks[Chosen]
  1268. end
  1269. if Track ~= nil then
  1270. gunEvent:Fire("PlayAudio",
  1271. {
  1272. Instance = Track,
  1273. Origin = ShootingHandle:FindFirstChild("GunMuzzlePoint"..CurrentFireMode),
  1274. Echo = TempModule.EchoEffect,
  1275. Silenced = TempModule.SilenceEffect
  1276. },
  1277. (TempModule.LowAmmo and CurrentVariables.Mag <= TempModule.AmmoPerMag / 5) and {
  1278. CurrentAmmo = CurrentVariables.Mag,
  1279. AmmoPerMag = TempModule.AmmoPerMag,
  1280. Instance = ShootingHandle[CurrentFireMode]:FindFirstChild(AddressTableValue("LowAmmoSound", TempModule)),
  1281. RaisePitch = TempModule.RaisePitch
  1282. } or nil, true)
  1283. end
  1284. end
  1285. local Misc = {
  1286. ChargeLevel = CurrentVariables.ChargeLevel,
  1287. LockedEntity = Target or LockedEntity,
  1288. MousePosition = MousePosition,
  1289. ModuleName = TempModule.ModuleName,
  1290. ModNames = ModNames,
  1291. FirstShot = FirstShot
  1292. }
  1293. gunEvent:Fire("VisualizeBullet",
  1294. Tool,
  1295. ShootingHandle,
  1296. FireDirections,
  1297. ShootingHandle:FindFirstChild("GunFirePoint"..CurrentFireMode),
  1298. ShootingHandle:FindFirstChild("GunMuzzlePoint"..CurrentFireMode),
  1299. Misc,
  1300. true)
  1301. local OnClientShootEventName = AddressTableValue("OnClientShootEventName", TempModule)
  1302. if OnClientShootEventName ~= "None" then
  1303. OnClientShootEvents[OnClientShootEventName](
  1304. AddressTableValue("OnClientShootEventData", TempModule),
  1305. Character,
  1306. Tool,
  1307. ShootingHandle,
  1308. FireDirections,
  1309. ShootingHandle:FindFirstChild("GunFirePoint"..CurrentFireMode),
  1310. ShootingHandle:FindFirstChild("GunMuzzlePoint"..CurrentFireMode),
  1311. Misc
  1312. )
  1313. end
  1314. local CanTrigger = true
  1315. if TempModule.LockOnScan and TempModule.InstaBurst then
  1316. CanTrigger = FirstShot
  1317. end
  1318. if CanTrigger then
  1319. Thread:Spawn(function()
  1320. if TempModule.CameraRecoilingEnabled then
  1321. local Recoil = AddressTableValue("Recoil", TempModule)
  1322. local CurrentRecoil = Recoil * (CommonVariables.AimDown and 1 - TempModule.ADSRecoilRedution or 1)
  1323. local RecoilX = math.rad(CurrentRecoil * Math.Randomize2(TempModule.AngleXMin, TempModule.AngleXMax, TempModule.Accuracy))
  1324. local RecoilY = math.rad(CurrentRecoil * Math.Randomize2(TempModule.AngleYMin, TempModule.AngleYMax, TempModule.Accuracy))
  1325. local RecoilZ = math.rad(CurrentRecoil * Math.Randomize2(TempModule.AngleZMin, TempModule.AngleZMax, TempModule.Accuracy))
  1326. Springs.Knockback:Accelerate(Vector3.new(-RecoilX * TempModule.ScopeKnockbackMultiplier, -RecoilY * TempModule.ScopeKnockbackMultiplier, 0))
  1327. Springs.CameraSpring:Accelerate(Vector3.new(RecoilX, RecoilY, RecoilZ))
  1328. Thread:Wait(0.03)
  1329. Springs.CameraSpring:Accelerate(Vector3.new(-RecoilX, -RecoilY, 0))
  1330. end
  1331. end)
  1332. Springs.CrossSpring:Accelerate(AddressTableValue("CrossExpansion", TempModule))
  1333. if AddressTableValue("SelfKnockback", TempModule) then
  1334. local SelfKnockbackPower = AddressTableValue("SelfKnockbackPower", TempModule)
  1335. local SelfKnockbackMultiplier = AddressTableValue("SelfKnockbackMultiplier", TempModule)
  1336. local SelfKnockbackRedution = AddressTableValue("SelfKnockbackRedution", TempModule)
  1337. local Power = Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and SelfKnockbackPower * SelfKnockbackMultiplier * (1 - SelfKnockbackRedution) or SelfKnockbackPower * SelfKnockbackMultiplier
  1338. local VelocityMod = (MousePosition - Torso.Position).Unit
  1339. local AirVelocity = Torso.Velocity - Vector3.new(0, Torso.Velocity.Y, 0) + Vector3.new(VelocityMod.X, 0, VelocityMod.Z) * -Power
  1340. local TorsoFly = Instance.new("BodyVelocity")
  1341. TorsoFly.MaxForce = Vector3.new(math.huge, 0, math.huge)
  1342. TorsoFly.Velocity = AirVelocity
  1343. TorsoFly.Parent = Torso
  1344. Torso.Velocity = Torso.Velocity + Vector3.new(0, VelocityMod.Y * 2, 0) * -Power
  1345. Debris:AddItem(TorsoFly, 0.25)
  1346. end
  1347. end
  1348. local CanTrigger2 = true
  1349. if TempModule.LockOnScan and TempModule.InstaBurst and TempModule.TriggerOnce then
  1350. CanTrigger2 = FirstShot
  1351. end
  1352. if not CanTrigger2 then
  1353. return
  1354. end
  1355. if TempModule.BatteryEnabled then
  1356. CurrentVariables.ShotsForDepletion = CurrentVariables.ShotsForDepletion + 1
  1357. if CurrentVariables.ShotsForDepletion >= TempModule.ShotsForDepletion then
  1358. CurrentVariables.ShotsForDepletion = 0
  1359. UniversalTable.Ammo = math.clamp(UniversalTable.Ammo - Random.new():NextInteger(AddressTableValue("MinDepletion", TempModule), AddressTableValue("MaxDepletion", TempModule)), 0, UniversalTable.MaxAmmo)
  1360. end
  1361. CurrentVariables.Heat = math.clamp(CurrentVariables.Heat + Random.new():NextInteger(AddressTableValue("HeatPerFireMin", TempModule), AddressTableValue("HeatPerFireMax", TempModule)), 0, TempModule.MaxHeat)
  1362. else
  1363. local LastMag = CurrentVariables.Mag
  1364. CurrentVariables.Mag = math.clamp(CurrentVariables.Mag - AddressTableValue("AmmoCost", TempModule), 0, TempModule.AmmoPerMag)
  1365. if Module.MagCartridge and not TempModule.BatteryEnabled and TempModule.AmmoPerMag ~= math.huge then
  1366. for i = 0, (LastMag - CurrentVariables.Mag) - 1 do
  1367. local Bullet = GUI.MagCartridge:FindFirstChild(LastMag - i)
  1368. if Module.Ejection then
  1369. local Vel = Random2DDirection(Module.Velocity, math.random(Module.XMin, Module.XMax), math.random(Module.YMin, Module.YMax)) * (math.random() ^ 0.5)
  1370. CreateCasing(Bullet.Rotation, Bullet.AbsolutePosition, Bullet.AbsoluteSize, Vel, "shell", Module.Shockwave)
  1371. end
  1372. Bullet.Visible = false
  1373. end
  1374. end
  1375. end
  1376. ChangeMagAndAmmo:FireServer(CurrentFireMode, CurrentVariables.Mag, UniversalTable.Ammo)
  1377. CommonVariables.ShootCounts = CommonVariables.ShootCounts - 1
  1378. if CommonVariables.ShootCounts <= 0 then
  1379. CommonVariables.ShootCounts = TempModule.ShootCounts
  1380. end
  1381. CurrentVariables.ShotID = CurrentVariables.ShotID + 1
  1382. local LastShotID = CurrentVariables.ShotID
  1383. Thread:Spawn(function()
  1384. CommonVariables.CanBeCooledDown = false
  1385. local Interrupted = false
  1386. local StartTime = os.clock() repeat Thread:Wait() if LastShotID ~= CurrentVariables.ShotID then break end until (os.clock() - StartTime) >= AddressTableValue("TimeBeforeCooldown", TempModule)
  1387. if LastShotID ~= CurrentVariables.ShotID then Interrupted = true end
  1388. if not Interrupted then
  1389. CommonVariables.CanBeCooledDown = true
  1390. end
  1391. end)
  1392. UpdateGUI()
  1393. if CurrentAnimTable.EmptyIdleAnim and CurrentVariables.Mag <= 0 then
  1394. if CurrentAnimTable.EmptyAimIdleAnim and CommonVariables.AimDown then
  1395. SetAnimationTrack("AimIdleAnim", "Stop")
  1396. SetAnimationTrack("EmptyAimIdleAnim", "Play", TempModule.EmptyAimIdleAnimationSpeed)
  1397. else
  1398. SetAnimationTrack("IdleAnim", "Stop")
  1399. SetAnimationTrack("EmptyIdleAnim", "Play", TempModule.EmptyIdleAnimationSpeed)
  1400. end
  1401. end
  1402. end
  1403.  
  1404. function CycleHandles()
  1405. CurrentVariables.HandleIndex = CurrentVariables.HandleIndex % #CurrentModule.Handles + 1
  1406. HandleToFire = Tool:FindFirstChild(CurrentModule.Handles[CurrentVariables.HandleIndex], true)
  1407.  
  1408. if #CurrentAnimTable.AimFireAnims > 0 then
  1409. CurrentVariables.AimFireAnimIndex = CurrentVariables.AimFireAnimIndex % #CurrentAnimTable.AimFireAnims + 1
  1410. CurrentAimFireAnim = CurrentAnimTable.AimFireAnims[CurrentVariables.AimFireAnimIndex][1]
  1411. CurrentAimFireAnimationSpeed = CurrentAnimTable.AimFireAnims[CurrentVariables.AimFireAnimIndex][2]
  1412. end
  1413. if #CurrentAnimTable.FireAnims > 0 then
  1414. CurrentVariables.FireAnimIndex = CurrentVariables.FireAnimIndex % #CurrentAnimTable.FireAnims + 1
  1415. CurrentFireAnim = CurrentAnimTable.FireAnims[CurrentVariables.FireAnimIndex][1]
  1416. CurrentFireAnimationSpeed = CurrentAnimTable.FireAnims[CurrentVariables.FireAnimIndex][2]
  1417. end
  1418. if #CurrentAnimTable.AimLastFireAnims > 0 then
  1419. CurrentVariables.AimLastFireAnimIndex = CurrentVariables.AimLastFireAnimIndex % #CurrentAnimTable.AimLastFireAnims + 1
  1420. CurrentAimLastFireAnim = CurrentAnimTable.AimLastFireAnims[CurrentVariables.AimLastFireAnimIndex][1]
  1421. CurrentAimLastFireAnimationSpeed = CurrentAnimTable.AimLastFireAnims[CurrentVariables.AimLastFireAnimIndex][2]
  1422. end
  1423. if #CurrentAnimTable.LastFireAnims > 0 then
  1424. CurrentVariables.LastFireAnimIndex = CurrentVariables.LastFireAnimIndex % #CurrentAnimTable.LastFireAnims + 1
  1425. CurrentLastFireAnim = CurrentAnimTable.LastFireAnims[CurrentVariables.LastFireAnimIndex][1]
  1426. CurrentLastFireAnimationSpeed = CurrentAnimTable.LastFireAnims[CurrentVariables.LastFireAnimIndex][2]
  1427. end
  1428. if #CurrentAnimTable.ShotgunPumpinAnims > 0 then
  1429. CurrentVariables.ShotgunPumpinAnimIndex = CurrentVariables.ShotgunPumpinAnimIndex % #CurrentAnimTable.ShotgunPumpinAnims + 1
  1430. CurrentShotgunPumpinAnim = CurrentAnimTable.ShotgunPumpinAnims[CurrentVariables.ShotgunPumpinAnimIndex][1]
  1431. CurrentShotgunPumpinAnimationSpeed = CurrentAnimTable.ShotgunPumpinAnims[CurrentVariables.ShotgunPumpinAnimIndex][2]
  1432. end
  1433. end
  1434.  
  1435. function SetADS(ForceDisable)
  1436. if not CurrentModule.ADSEnabled then
  1437. return
  1438. end
  1439. local Info
  1440. local function Disable()
  1441. Info = TweenInfo.new(CurrentModule.TweenLengthNAD, CurrentModule.EasingStyleNAD, CurrentModule.EasingDirectionNAD)
  1442. TweenService:Create(Camera, Info, {FieldOfView = 70}):Play()
  1443. SetCrossScale(1)
  1444. if CommonVariables.ActuallyEquipped then
  1445. SetAnimationTrack("AimIdleAnim", "Stop")
  1446. SetAnimationTrack("EmptyAimIdleAnim", "Stop")
  1447. if CurrentAnimTable.EmptyIdleAnim and CurrentVariables.Mag <= 0 then
  1448. SetAnimationTrack("EmptyIdleAnim", "Play", CurrentModule.EmptyIdleAnimationSpeed)
  1449. else
  1450. SetAnimationTrack("IdleAnim", "Play", CurrentModule.IdleAnimationSpeed)
  1451. end
  1452. end
  1453. UserInputService.MouseDeltaSensitivity = CommonVariables.InitialSensitivity
  1454. CommonVariables.AimDown = false
  1455. CommonVariables.Scoping = false
  1456. if CurrentModule.HideCrosshair then
  1457. TweenService:Create(CurrentCrosshair, Info, {GroupTransparency = 0}):Play()
  1458. end
  1459. Player.CameraMode = Enum.CameraMode.Classic
  1460. end
  1461. if ForceDisable then
  1462. Disable()
  1463. return
  1464. end
  1465. if not CommonVariables.Equipped then
  1466. return
  1467. end
  1468. if not CommonVariables.Reloading and not CommonVariables.Overheated and not CommonVariables.HoldDown and not CommonVariables.Switching and not CommonVariables.Alting and not CommonVariables.AimDown and CommonVariables.ActuallyEquipped then
  1469. Info = TweenInfo.new(CurrentModule.TweenLength, CurrentModule.EasingStyle, CurrentModule.EasingDirection)
  1470. TweenService:Create(Camera, Info, {FieldOfView = CurrentModule.ADSFieldOfView}):Play()
  1471. SetCrossScale(CurrentModule.ADSCrossScale)
  1472. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  1473. if CurrentAnimTable.AimIdleAnim then
  1474. SetAnimationTrack("IdleAnim", "Stop")
  1475. SetAnimationTrack("EmptyIdleAnim", "Stop")
  1476. if CurrentAnimTable.EmptyAimIdleAnim and CurrentVariables.Mag <= 0 then
  1477. SetAnimationTrack("EmptyAimIdleAnim", "Play", CurrentModule.EmptyAimIdleAnimationSpeed)
  1478. else
  1479. SetAnimationTrack("AimIdleAnim", "Play", CurrentModule.AimIdleAnimationSpeed)
  1480. end
  1481. end
  1482. UserInputService.MouseDeltaSensitivity = CommonVariables.InitialSensitivity * CurrentModule.ADSMouseSensitivity
  1483. CommonVariables.AimDown = true
  1484. if CurrentModule.HideCrosshair then
  1485. TweenService:Create(CurrentCrosshair, Info, {GroupTransparency = 1}):Play()
  1486. end
  1487. if not Module.ThirdPersonADS then
  1488. Player.CameraMode = Enum.CameraMode.LockFirstPerson
  1489. else
  1490. if Module.ForceFirstPerson then
  1491. Player.CameraMode = Enum.CameraMode.LockFirstPerson
  1492. end
  1493. end
  1494. if CurrentModule.ADSType == "Sniper" then
  1495. local StartTime = os.clock() repeat Thread:Wait() if not (CommonVariables.ActuallyEquipped or CommonVariables.AimDown) then break end until (os.clock() - StartTime) >= CurrentModule.ScopeDelay
  1496. if CommonVariables.ActuallyEquipped and CommonVariables.AimDown then
  1497. GUI.Scope.ZoomSound:Play()
  1498. CommonVariables.Scoping = true
  1499. end
  1500. end
  1501. else
  1502. Disable()
  1503. end
  1504. end
  1505.  
  1506. function SetChargeEffect(ChargeLevel, ChargeEffect)
  1507. gunEvent:Fire("VisualizeCharge", ChargeEffect, "Begin", Character, Tool, HandleToFire, ChargeLevel, true)
  1508. end
  1509.  
  1510. function RemoveStuff(StopSounds)
  1511. for i, v in pairs(CommonVariables.KeyframeConnections) do
  1512. v:Disconnect()
  1513. table.remove(CommonVariables.KeyframeConnections, i)
  1514. end
  1515. LockedEntity = nil
  1516. TargetMarker.Enabled = false
  1517. TargetMarker.Parent = script
  1518. TargetMarker.Adornee = nil
  1519. if CommonVariables.Radar then
  1520. CommonVariables.Radar:Destroy()
  1521. CommonVariables.Radar = nil
  1522. end
  1523. if CommonVariables.Beam then
  1524. CommonVariables.Beam:Destroy()
  1525. CommonVariables.Beam = nil
  1526. end
  1527. if CommonVariables.Attach0 then
  1528. CommonVariables.Attach0:Destroy()
  1529. CommonVariables.Attach0 = nil
  1530. end
  1531. if CommonVariables.Attach1 then
  1532. CommonVariables.Attach1:Destroy()
  1533. CommonVariables.Attach1 = nil
  1534. end
  1535. for _, a in pairs(CurrentAnimTable) do
  1536. if typeof(a) == "table" then
  1537. for _, a2 in pairs(a) do
  1538. --SetAnimationTrack(a2[1].Animation.Name, "Stop", nil, nil, "IsPlaying")
  1539. if a2[1].IsPlaying then
  1540. a2[1]:Stop()
  1541. end
  1542. end
  1543. else
  1544. --SetAnimationTrack(a.Animation.Name, "Stop", nil, nil, "IsPlaying")
  1545. if a.IsPlaying then
  1546. a:Stop()
  1547. end
  1548. end
  1549. end
  1550. if StopSounds then
  1551. for _, h in pairs(CurrentModule.Handles) do
  1552. local handle = Tool:FindFirstChild(h, true)
  1553. if handle then
  1554. for _, s in pairs(handle[CurrentFireMode]:GetChildren()) do
  1555. if s:IsA("Sound") and s.IsPlaying then
  1556. s:Stop()
  1557. end
  1558. end
  1559. end
  1560. end
  1561. end
  1562. end
  1563.  
  1564. function Overheat()
  1565. if CommonVariables.ActuallyEquipped and CommonVariables.Enabled and not CommonVariables.Overheated and CurrentVariables.Heat >= CurrentModule.MaxHeat then
  1566. CommonVariables.Overheated = true
  1567. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  1568. SetADS(true)
  1569. UpdateGUI()
  1570. if CommonVariables.ActuallyEquipped then
  1571. SetAnimationTrack("OverheatAnim", "Play", CurrentModule.OverheatAnimationSpeed)
  1572. HandleToFire[CurrentFireMode].OverheatSound:Play()
  1573. gunEvent:Fire("VisualizeOverheat", CurrentModule.OverheatEffect, "Begin", Character, Tool, HandleToFire, true)
  1574. end
  1575. --Thread:Wait(CurrentModule.OverheatTime)
  1576. for i = 1, CurrentModule.MaxHeat do
  1577. Thread:Wait(CurrentModule.OverheatTime / CurrentModule.MaxHeat)
  1578. CurrentVariables.Heat = CurrentVariables.Heat - 1
  1579. UpdateGUI()
  1580. if CurrentVariables.Heat == 0 then
  1581. CommonVariables.Overheated = false
  1582. break
  1583. end
  1584. end
  1585. CommonVariables.Overheated = false
  1586. UpdateGUI()
  1587. if CommonVariables.ActuallyEquipped then
  1588. gunEvent:Fire("VisualizeOverheat", CurrentModule.OverheatEffect, "End", Character, Tool, HandleToFire, true)
  1589. end
  1590. end
  1591. end
  1592.  
  1593. function Reload()
  1594. if CommonVariables.ActuallyEquipped and CommonVariables.Enabled and not CommonVariables.Reloading and (UniversalTable.Ammo > 0 or not (Module.UniversalAmmoEnabled or CurrentModule.LimitedAmmoEnabled)) and CurrentVariables.Mag < CurrentModule.AmmoPerMag then
  1595. CommonVariables.Reloading = true
  1596. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  1597. SetADS(true)
  1598. UpdateGUI()
  1599. local function PlayIdleAnim()
  1600. SetAnimationTrack("IdleAnim", "Stop")
  1601. SetAnimationTrack("EmptyIdleAnim", "Stop")
  1602. SetAnimationTrack("AimIdleAnim", "Stop")
  1603. SetAnimationTrack("EmptyAimIdleAnim", "Stop")
  1604. if CurrentAnimTable.EmptyIdleAnim and CurrentVariables.Mag <= 0 then
  1605. if CurrentAnimTable.EmptyAimIdleAnim and CommonVariables.AimDown then
  1606. SetAnimationTrack("EmptyAimIdleAnim", "Play", CurrentModule.EmptyAimIdleAnimationSpeed)
  1607. else
  1608. SetAnimationTrack("EmptyIdleAnim", "Play", CurrentModule.EmptyIdleAnimationSpeed)
  1609. end
  1610. else
  1611. if CurrentAnimTable.AimIdleAnim and CommonVariables.AimDown then
  1612. SetAnimationTrack("AimIdleAnim", "Play", CurrentModule.AimIdleAnimationSpeed)
  1613. else
  1614. SetAnimationTrack("IdleAnim", "Play", CurrentModule.IdleAnimationSpeed)
  1615. end
  1616. end
  1617. end
  1618. if CurrentModule.ShotgunReload then
  1619. if CurrentModule.PreShotgunReload then
  1620. if CommonVariables.ActuallyEquipped then
  1621. SetAnimationTrack("PreShotgunReloadAnim", "Play", CurrentModule.PreShotgunReloadAnimationSpeed)
  1622. HandleToFire[CurrentFireMode].PreReloadSound:Play()
  1623. end
  1624. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped or CommonVariables.CanCancelReload then
  1625. if CommonVariables.ActuallyEquipped and CommonVariables.CanCancelReload then
  1626. PlayIdleAnim()
  1627. SetAnimationTrack("PreShotgunReloadAnim", "Stop")
  1628. if HandleToFire[CurrentFireMode].PreReloadSound.Playing then
  1629. HandleToFire[CurrentFireMode].PreReloadSound:Stop()
  1630. end
  1631. end
  1632. break
  1633. end
  1634. until (os.clock() - StartTime) >= CurrentModule.PreShotgunReloadSpeed
  1635. --Thread:Wait(CurrentModule.PreShotgunReloadSpeed)
  1636. end
  1637. for i = 1, (CurrentModule.AmmoPerMag - CurrentVariables.Mag) do
  1638. if CommonVariables.ActuallyEquipped then
  1639. SetAnimationTrack("ShotgunClipinAnim", "Play", CurrentModule.ShotgunClipinAnimationSpeed)
  1640. HandleToFire[CurrentFireMode].ShotgunClipin:Play()
  1641. end
  1642. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped or CommonVariables.CanCancelReload then
  1643. if CommonVariables.ActuallyEquipped and CommonVariables.CanCancelReload then
  1644. PlayIdleAnim()
  1645. SetAnimationTrack("ShotgunClipinAnim", "Stop")
  1646. if HandleToFire[CurrentFireMode].ShotgunClipin.Playing then
  1647. HandleToFire[CurrentFireMode].ShotgunClipin:Stop()
  1648. end
  1649. end
  1650. break
  1651. end
  1652. until (os.clock() - StartTime) >= CurrentModule.ShellClipinSpeed
  1653. --Thread:Wait(CurrentModule.ShellClipinSpeed)
  1654. if CommonVariables.CanCancelReload then
  1655. break
  1656. end
  1657. if CurrentVariables.Mag < CurrentModule.AmmoPerMag then
  1658. if CommonVariables.ActuallyEquipped then
  1659. if (Module.UniversalAmmoEnabled or CurrentModule.LimitedAmmoEnabled) and UniversalTable.MaxAmmo ~= math.huge then
  1660. if UniversalTable.Ammo > 0 then
  1661. CurrentVariables.Mag = CurrentVariables.Mag + 1
  1662. UniversalTable.Ammo = UniversalTable.Ammo - 1
  1663. if Module.MagCartridge and not CurrentModule.BatteryEnabled then
  1664. for i = 1, CurrentVariables.Mag do
  1665. GUI.MagCartridge[i].Visible = true
  1666. end
  1667. end
  1668. UpdateGUI()
  1669. end
  1670. else
  1671. CurrentVariables.Mag = CurrentVariables.Mag + 1
  1672. UpdateGUI()
  1673. end
  1674. ChangeMagAndAmmo:FireServer(CurrentFireMode, CurrentVariables.Mag, UniversalTable.Ammo)
  1675. end
  1676. else
  1677. break
  1678. end
  1679. if (Module.UniversalAmmoEnabled or CurrentModule.LimitedAmmoEnabled) and UniversalTable.MaxAmmo ~= math.huge then
  1680. if not CommonVariables.ActuallyEquipped or UniversalTable.Ammo <= 0 then
  1681. break
  1682. end
  1683. else
  1684. if not CommonVariables.ActuallyEquipped then
  1685. break
  1686. end
  1687. end
  1688. end
  1689. end
  1690. if CommonVariables.ActuallyEquipped and not CommonVariables.CanCancelReload then
  1691. if CurrentModule.TacticalReloadAnimationEnabled then
  1692. if CurrentVariables.Mag > 0 then
  1693. SetAnimationTrack("TacticalReloadAnim", "Play", CurrentModule.TacticalReloadAnimationSpeed)
  1694. HandleToFire[CurrentFireMode].TacticalReloadSound:Play()
  1695. else
  1696. SetAnimationTrack("ReloadAnim", "Play", CurrentModule.ReloadAnimationSpeed)
  1697. HandleToFire[CurrentFireMode].ReloadSound:Play()
  1698. end
  1699. else
  1700. SetAnimationTrack("ReloadAnim", "Play", CurrentModule.ReloadAnimationSpeed)
  1701. HandleToFire[CurrentFireMode].ReloadSound:Play()
  1702. end
  1703. end
  1704. local ReloadTime = (CurrentVariables.Mag > 0 and CurrentModule.TacticalReloadAnimationEnabled) and CurrentModule.TacticalReloadTime or CurrentModule.ReloadTime
  1705. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped or CommonVariables.CanCancelReload then
  1706. if CommonVariables.ActuallyEquipped and CommonVariables.CanCancelReload then
  1707. PlayIdleAnim()
  1708. SetAnimationTrack("TacticalReloadAnim", "Stop")
  1709. if HandleToFire[CurrentFireMode].TacticalReloadSound.Playing then
  1710. HandleToFire[CurrentFireMode].TacticalReloadSound:Stop()
  1711. end
  1712. SetAnimationTrack("ReloadAnim", "Stop")
  1713. if HandleToFire[CurrentFireMode].ReloadSound.Playing then
  1714. HandleToFire[CurrentFireMode].ReloadSound:Stop()
  1715. end
  1716. end
  1717. break
  1718. end
  1719. until (os.clock() - StartTime) >= ReloadTime
  1720. --Thread:Wait((CurrentVariables.Mag > 0 and CurrentModule.TacticalReloadAnimationEnabled) and CurrentModule.TacticalReloadTime or CurrentModule.ReloadTime)
  1721. if CommonVariables.ActuallyEquipped and not CommonVariables.CanCancelReload then
  1722. if not CurrentModule.ShotgunReload then
  1723. if Module.MagCartridge and Module.DropAllRemainingBullets and not CurrentModule.BatteryEnabled then
  1724. for i = 1, CurrentVariables.Mag do
  1725. local Bullet = GUI.MagCartridge:FindFirstChild(i)
  1726. local Vel = Random2DDirection(Module.DropVelocity, math.random(Module.DropXMin, Module.DropXMax), math.random(Module.DropYMin, Module.DropYMax)) * (math.random() ^ 0.5)
  1727. CreateCasing(Bullet.Rotation, Bullet.AbsolutePosition, Bullet.AbsoluteSize, Vel, "Bullet")
  1728. end
  1729. end
  1730. if (Module.UniversalAmmoEnabled or CurrentModule.LimitedAmmoEnabled) and UniversalTable.MaxAmmo ~= math.huge then
  1731. local AmmoToUse = math.min(CurrentModule.AmmoPerMag - CurrentVariables.Mag, UniversalTable.Ammo)
  1732. CurrentVariables.Mag = CurrentVariables.Mag + AmmoToUse
  1733. UniversalTable.Ammo = UniversalTable.Ammo - AmmoToUse
  1734. else
  1735. CurrentVariables.Mag = CurrentModule.AmmoPerMag
  1736. end
  1737. ChangeMagAndAmmo:FireServer(CurrentFireMode, CurrentVariables.Mag, UniversalTable.Ammo)
  1738. end
  1739. PlayIdleAnim()
  1740. end
  1741. CommonVariables.Reloading = false
  1742. CommonVariables.CanCancelReload = false
  1743. if Module.MagCartridge and not CurrentModule.BatteryEnabled then
  1744. for i = 1, CurrentVariables.Mag do
  1745. GUI.MagCartridge[i].Visible = true
  1746. end
  1747. end
  1748. UpdateGUI()
  1749. end
  1750. end
  1751.  
  1752. function OnHoldingDown()
  1753. if CurrentModule.HoldDownEnabled then
  1754. if not CommonVariables.Reloading and not CommonVariables.Overheated and CommonVariables.ActuallyEquipped and CommonVariables.Enabled then
  1755. if not CommonVariables.HoldDown then
  1756. CommonVariables.HoldDown = true
  1757. SetAnimationTrack("AimIdleAnim", "Stop")
  1758. SetAnimationTrack("IdleAnim", "Stop")
  1759. SetAnimationTrack("HoldDownAnim", "Play", CurrentModule.HoldDownAnimationSpeed)
  1760. script.ADS:Play()
  1761. SetADS(true)
  1762. else
  1763. CommonVariables.HoldDown = false
  1764. SetAnimationTrack("IdleAnim", "Play", CurrentModule.IdleAnimationSpeed)
  1765. script.ADS:Play()
  1766. SetAnimationTrack("HoldDownAnim", "Stop")
  1767. end
  1768. end
  1769. end
  1770. end
  1771.  
  1772. function OnInspecting()
  1773. if not CommonVariables.Reloading and not CommonVariables.Overheated and CommonVariables.ActuallyEquipped and CommonVariables.Enabled and not CommonVariables.AimDown and not CommonVariables.Inspecting and not CommonVariables.Switching and not CommonVariables.Alting and CurrentModule.InspectAnimationEnabled then
  1774. CommonVariables.Inspecting = true
  1775. local AnimationSpeed = CurrentAnimTable.InspectAnim and CurrentModule.InspectAnimationSpeed or 0
  1776. local AnimationLength = CurrentAnimTable.InspectAnim and CurrentAnimTable.InspectAnim.Length or 0
  1777. if CurrentVariables.Mag <= 0 then
  1778. AnimationSpeed = CurrentAnimTable.EmptyInspectAnim and CurrentModule.EmptyInspectAnimationSpeed or (CurrentAnimTable.InspectAnim and CurrentModule.InspectAnimationSpeed or 0)
  1779. AnimationLength = CurrentAnimTable.EmptyInspectAnim and CurrentAnimTable.EmptyInspectAnim.Length or (CurrentAnimTable.InspectAnim and CurrentAnimTable.InspectAnim.Length or 0)
  1780. end
  1781. SetAnimationTrack("InspectAnim", "Play", AnimationSpeed)
  1782. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped or CommonVariables.Reloading or CommonVariables.Overheated or not CommonVariables.Enabled or CommonVariables.AimDown or CommonVariables.Switching or CommonVariables.Alting then break end until (os.clock() - StartTime) >= AnimationLength / AnimationSpeed
  1783. CommonVariables.Inspecting = false
  1784. end
  1785. end
  1786.  
  1787. function OnSwitching()
  1788. if not CommonVariables.Reloading and not CommonVariables.Overheated and CommonVariables.ActuallyEquipped and CommonVariables.Enabled and not CommonVariables.Switching and not CommonVariables.Alting and CurrentModule.SelectiveFireEnabled then
  1789. CommonVariables.Switching = true
  1790. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  1791. SetAnimationTrack("SwitchAnim", "Play", CurrentModule.SwitchAnimationSpeed)
  1792. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped or CommonVariables.Reloading or CommonVariables.Overheated or not CommonVariables.Enabled then break end until (os.clock() - StartTime) >= CurrentModule.SwitchTime
  1793. CommonVariables.Switching = false
  1794. if CommonVariables.ActuallyEquipped and not CommonVariables.Reloading and not CommonVariables.Overheated and CommonVariables.Enabled then
  1795. HandleToFire[CurrentFireMode].SwitchSound:Play()
  1796. CurrentVariables.FireMode = CurrentVariables.FireMode % #CurrentVariables.FireModes + 1
  1797. UpdateGUI()
  1798. end
  1799. end
  1800. end
  1801.  
  1802. function OnAlting()
  1803. if Module.AltFire and #Setting:GetChildren() > 1 then
  1804. if not CommonVariables.Reloading and not CommonVariables.Overheated and CommonVariables.ActuallyEquipped and CommonVariables.Enabled and not CommonVariables.HoldDown and not CommonVariables.Alting and not CommonVariables.Switching then
  1805. CommonVariables.Alting = true
  1806. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  1807. SetADS(true)
  1808. SetAnimationTrack("AltAnim", "Play", CurrentModule.AltAnimationSpeed)
  1809. HandleToFire[CurrentFireMode].AltSound:Play()
  1810. local Interrupted = false
  1811. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped or CommonVariables.Reloading or CommonVariables.Overheated or not CommonVariables.Enabled then Interrupted = true break end until (os.clock() - StartTime) >= CurrentModule.AltTime
  1812. if Interrupted then
  1813. SetAnimationTrack("AltAnim", "Stop")
  1814. HandleToFire[CurrentFireMode].AltSound:Stop()
  1815. end
  1816. CommonVariables.Alting = false
  1817. if CommonVariables.ActuallyEquipped and not CommonVariables.Reloading and not CommonVariables.Overheated and CommonVariables.Enabled then
  1818. RemoveStuff()
  1819.  
  1820. HandleToFire = Tool:FindFirstChild(CurrentModule.Handles[1], true)
  1821.  
  1822. CommonVariables.CurrentRate = 0
  1823. CommonVariables.LastRate = 0
  1824. CommonVariables.ElapsedTime = 0
  1825.  
  1826. CurrentFireMode = CurrentFireMode % #Settings + 1
  1827. CurrentModule = CommonVariables.SettingModules[CurrentFireMode]
  1828. CurrentVariables = Variables[CurrentFireMode]
  1829. CurrentAnimTable = CommonVariables.Animations[CurrentFireMode]
  1830. CurrentCrosshair = GUI.Crosshair[CurrentFireMode]
  1831.  
  1832. for i, v in pairs(GUI.Crosshair:GetChildren()) do
  1833. if v:IsA("CanvasGroup") then
  1834. v.Visible = (tonumber(v.Name) == CurrentFireMode)
  1835. end
  1836. end
  1837.  
  1838. CommonVariables.ShootCounts = CurrentModule.ShootCounts
  1839.  
  1840. if not Module.UniversalAmmoEnabled then
  1841. UniversalTable = CurrentVariables
  1842. end
  1843.  
  1844. CurrentVariables.HandleIndex = 1
  1845. CurrentVariables.FireAnimIndex = 1
  1846. CurrentVariables.LastFireAnimIndex = 1
  1847. CurrentVariables.AimFireAnimIndex = 1
  1848. CurrentVariables.AimLastFireAnimIndex = 1
  1849. CurrentVariables.ShotgunPumpinAnimIndex = 1
  1850.  
  1851. CurrentAimFireAnim = #CurrentAnimTable.AimFireAnims > 0 and CurrentAnimTable.AimFireAnims[1][1] or nil
  1852. CurrentAimFireAnimationSpeed = #CurrentAnimTable.AimFireAnims > 0 and CurrentAnimTable.AimFireAnims[1][2] or nil
  1853.  
  1854. CurrentFireAnim = #CurrentAnimTable.FireAnims > 0 and CurrentAnimTable.FireAnims[1][1] or nil
  1855. CurrentFireAnimationSpeed = #CurrentAnimTable.FireAnims > 0 and CurrentAnimTable.FireAnims[1][2] or nil
  1856.  
  1857. CurrentAimLastFireAnim = #CurrentAnimTable.AimLastFireAnims > 0 and CurrentAnimTable.AimLastFireAnims[1][1] or nil
  1858. CurrentAimLastFireAnimationSpeed = #CurrentAnimTable.AimLastFireAnims > 0 and CurrentAnimTable.AimLastFireAnims[1][2] or nil
  1859.  
  1860. CurrentLastFireAnim = #CurrentAnimTable.LastFireAnims > 0 and CurrentAnimTable.LastFireAnims[1][1] or nil
  1861. CurrentLastFireAnimationSpeed = #CurrentAnimTable.LastFireAnims > 0 and CurrentAnimTable.LastFireAnims[1][2] or nil
  1862.  
  1863. CurrentShotgunPumpinAnim = #CurrentAnimTable.ShotgunPumpinAnims > 0 and CurrentAnimTable.ShotgunPumpinAnims[1][1] or nil
  1864. CurrentShotgunPumpinAnimationSpeed = #CurrentAnimTable.ShotgunPumpinAnims > 0 and CurrentAnimTable.ShotgunPumpinAnims[1][2] or nil
  1865.  
  1866. Springs.Scope.s = CurrentModule.ScopeSwaySpeed
  1867. Springs.Scope.d = CurrentModule.ScopeSwayDamper
  1868.  
  1869. Springs.Knockback.s = CurrentModule.ScopeKnockbackSpeed
  1870. Springs.Knockback.d = CurrentModule.ScopeKnockbackDamper
  1871.  
  1872. Springs.CameraSpring.s = CurrentModule.RecoilSpeed
  1873. Springs.CameraSpring.d = CurrentModule.RecoilDamper
  1874.  
  1875. for i, v in pairs(BeamTable) do
  1876. if v then
  1877. v:Destroy()
  1878. end
  1879. end
  1880. table.clear(BeamTable)
  1881. CrosshairPointAttachment:ClearAllChildren()
  1882. LaserBeamEffect = GunVisualEffects:FindFirstChild(CurrentModule.LaserBeamEffect)
  1883. if LaserBeamEffect then
  1884. for i, v in pairs(LaserBeamEffect.HitEffect:GetChildren()) do
  1885. if v.ClassName == "ParticleEmitter" then
  1886. local particle = v:Clone()
  1887. particle.Enabled = true
  1888. particle.Parent = CrosshairPointAttachment
  1889. end
  1890. end
  1891. for i, v in pairs(LaserBeamEffect.LaserBeams:GetChildren()) do
  1892. if v.ClassName == "Beam" then
  1893. local beam = v:Clone()
  1894. table.insert(BeamTable, beam)
  1895. end
  1896. end
  1897. end
  1898.  
  1899. table.clear(CommonVariables.Keyframes)
  1900. for _, a in pairs(CurrentAnimTable) do
  1901. if typeof(a) == "table" then
  1902. for _, a2 in pairs(a) do
  1903. FindAnimationNameForKeyframe(a2[1])
  1904. end
  1905. else
  1906. FindAnimationNameForKeyframe(a)
  1907. end
  1908. end
  1909. for _, v in pairs(CommonVariables.Keyframes) do
  1910. table.insert(CommonVariables.KeyframeConnections, v[1]:GetMarkerReachedSignal("AnimationEvents"):Connect(function(keyframeName)
  1911. if v[2][keyframeName] then
  1912. v[2][keyframeName](keyframeName, Tool)
  1913. end
  1914. end))
  1915. end
  1916.  
  1917. if Module.MagCartridge and not CurrentModule.BatteryEnabled and CurrentModule.AmmoPerMag ~= math.huge then
  1918. for _, v in pairs(GUI.MagCartridge:GetChildren()) do
  1919. if not v:IsA("UIGridLayout") then
  1920. v:Destroy()
  1921. end
  1922. end
  1923. for i = 1, CurrentModule.AmmoPerMag do
  1924. local Bullet = GUI.MagCartridge.UIGridLayout.Template:Clone()
  1925. Bullet.Name = i
  1926. Bullet.LayoutOrder = i
  1927. if i > CurrentVariables.Mag then
  1928. Bullet.Visible = false
  1929. end
  1930. Bullet.Parent = GUI.MagCartridge
  1931. end
  1932. end
  1933.  
  1934. CommonVariables.Radar = Scanners.Radars[CurrentModule.Radar]:Clone()
  1935. CommonVariables.Radar.Name = "Scanner"
  1936. CommonVariables.Radar.Parent = GUI
  1937.  
  1938. SmokeTrail:StopEmission()
  1939.  
  1940. if CurrentModule.ProjectileMotion then
  1941. local MotionBeam = GunVisualEffects:FindFirstChild(CurrentModule.MotionBeam)
  1942. if MotionBeam then
  1943. CommonVariables.Beam, CommonVariables.Attach0, CommonVariables.Attach1 = ProjectileMotion.ShowProjectilePath(MotionBeam, HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode).WorldPosition, Vector3.new(), 3, AddressTableValue("Acceleration", CurrentModule))
  1944. end
  1945. end
  1946.  
  1947. if CurrentAnimTable.EmptyIdleAnim and CurrentVariables.Mag <= 0 then
  1948. SetAnimationTrack("EmptyIdleAnim", "Play", CurrentModule.EmptyIdleAnimationSpeed)
  1949. else
  1950. SetAnimationTrack("IdleAnim", "Play", CurrentModule.IdleAnimationSpeed)
  1951. end
  1952.  
  1953. UpdateGUI()
  1954.  
  1955. SetCrossSettings(CurrentModule.CrossSize, CurrentModule.CrossSpeed, CurrentModule.CrossDamper)
  1956.  
  1957. if CommonVariables.ActuallyEquipped and Module.AutoReload and CurrentVariables.Mag <= 0 then
  1958. Reload()
  1959. end
  1960. end
  1961. end
  1962. end
  1963. end
  1964.  
  1965. function OnFiring()
  1966. local function HasEnoughMag(AmmoCost)
  1967. return CurrentVariables.Mag >= AmmoCost
  1968. end
  1969. if CurrentModule.LaserBeam then
  1970. CommonVariables.Down = true
  1971. if CommonVariables.ActuallyEquipped and CommonVariables.Enabled and CommonVariables.Down and not CommonVariables.Overheated and not CommonVariables.HoldDown and not CommonVariables.Switching and not CommonVariables.Alting and HasEnoughMag(CurrentModule.AmmoCost) and CurrentVariables.Heat < CurrentModule.MaxHeat and Humanoid.Health > 0 and CanShoot() then
  1972. if Module.CancelReload then
  1973. if CommonVariables.Reloading and not CommonVariables.CanCancelReload then
  1974. CommonVariables.CanCancelReload = true
  1975. end
  1976. else
  1977. if CommonVariables.Reloading then
  1978. return
  1979. end
  1980. end
  1981. CommonVariables.Enabled = false
  1982. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  1983. if CurrentModule.LaserBeamStartupDelay > 0 then
  1984. SetAnimationTrack("LaserBeamStartupAnim", "Play", CurrentModule.LaserBeamStartupAnimationSpeed)
  1985. if CommonVariables.ActuallyEquipped and HandleToFire[CurrentFireMode]:FindFirstChild("BeamStartupSound") then
  1986. HandleToFire[CurrentFireMode].BeamStartupSound:Play()
  1987. end
  1988. local Interrupted = false
  1989. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then Interrupted = true break end until (os.clock() - StartTime) >= CurrentModule.LaserBeamStartupDelay
  1990. if Interrupted then
  1991. SetAnimationTrack("LaserBeamStartupAnim", "Stop")
  1992. if HandleToFire[CurrentFireMode]:FindFirstChild("BeamStartupSound") then
  1993. HandleToFire[CurrentFireMode].BeamStartupSound:Stop()
  1994. end
  1995. end
  1996. --Thread:Wait(CurrentModule.LaserBeamStartupDelay)
  1997. end
  1998. local Start = false
  1999. local MuzzlePoint = HandleToFire:FindFirstChild("GunMuzzlePoint"..CurrentFireMode)
  2000. local FirePoint = HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode)
  2001. while CommonVariables.ActuallyEquipped and not CommonVariables.Overheated and not CommonVariables.HoldDown and CommonVariables.Down and not CommonVariables.Switching and not CommonVariables.Alting and HasEnoughMag(CurrentModule.AmmoCost) and CurrentVariables.Heat < CurrentModule.MaxHeat and Humanoid.Health > 0 and CanShoot() do
  2002. SetAnimationTrack("LaserBeamLoopAnim", "Play", CurrentModule.LaserBeamLoopAnimationSpeed, nil, "IsNotPlaying")
  2003. if not HandleToFire[CurrentFireMode].BeamLoopSound.Playing or not HandleToFire[CurrentFireMode].BeamLoopSound.Looped then
  2004. HandleToFire[CurrentFireMode].BeamLoopSound:Play()
  2005. end
  2006. local FireDirection = (Get3DPosition2() - FirePoint.WorldPosition).Unit
  2007. local Hit, Pos, Normal, Material = CastRay("Beam", FirePoint.WorldPosition, FireDirection, CurrentModule.LaserBeamRange, IgnoreList, true)
  2008. if not Start then
  2009. Start = true
  2010. HandleToFire[CurrentFireMode].BeamFireSound:Play()
  2011. VisibleMuzz(MuzzlePoint, true)
  2012. VisibleMuzzle:FireServer(MuzzlePoint, true)
  2013. for i, v in pairs(BeamTable) do
  2014. if v then
  2015. v.Parent = HandleToFire
  2016. v.Attachment0 = FirePoint
  2017. v.Attachment1 = CrosshairPointAttachment
  2018. end
  2019. end
  2020. if CurrentModule.LaserTrailEnabled then
  2021. CommonVariables.LaserTrail = Miscs[CurrentModule.LaserTrailShape.."Segment"]:Clone()
  2022. CommonVariables.LaserTrail.CastShadow = false
  2023. if CurrentModule.RandomizeLaserColorIn == "None" then
  2024. CommonVariables.LaserTrail.Color = CurrentModule.LaserTrailColor
  2025. end
  2026. CommonVariables.LaserTrail.Material = CurrentModule.LaserTrailMaterial
  2027. CommonVariables.LaserTrail.Reflectance = CurrentModule.LaserTrailReflectance
  2028. CommonVariables.LaserTrail.Transparency = CurrentModule.LaserTrailTransparency
  2029. CommonVariables.LaserTrail.Size = CurrentModule.LaserTrailShape == "Cone" and Vector3.new(CurrentModule.LaserTrailWidth, (FirePoint.WorldPosition - Pos).Magnitude, CurrentModule.LaserTrailHeight) or Vector3.new((FirePoint.WorldPosition - Pos).Magnitude, CurrentModule.LaserTrailHeight, CurrentModule.LaserTrailWidth)
  2030. CommonVariables.LaserTrail.CFrame = CFrame.new((FirePoint.WorldPosition + Pos) * 0.5, Pos) * (CurrentModule.LaserTrailShape == "Cone" and CFrame.Angles(math.pi / 2, 0, 0) or CFrame.Angles(0, math.pi / 2, 0))
  2031. CommonVariables.LaserTrail.Parent = Camera
  2032. end
  2033. end
  2034. if CommonVariables.LaserTrail then
  2035. if CurrentModule.RandomizeLaserColorIn ~= "None" then
  2036. local Hue = os.clock() % CurrentModule.LaserColorCycleTime / CurrentModule.LaserColorCycleTime
  2037. local Color = Color3.fromHSV(Hue, 1, 1)
  2038. CommonVariables.LaserTrail.Color = Color
  2039. end
  2040. CommonVariables.LaserTrail.Size = CurrentModule.LaserTrailShape == "Cone" and Vector3.new(CurrentModule.LaserTrailWidth, (FirePoint.WorldPosition - Pos).Magnitude, CurrentModule.LaserTrailHeight) or Vector3.new((FirePoint.WorldPosition - Pos).Magnitude, CurrentModule.LaserTrailHeight, CurrentModule.LaserTrailWidth)
  2041. CommonVariables.LaserTrail.CFrame = CFrame.new((FirePoint.WorldPosition + Pos) * 0.5, Pos) * (CurrentModule.LaserTrailShape == "Cone" and CFrame.Angles(math.pi / 2, 0, 0) or CFrame.Angles(0, math.pi / 2, 0))
  2042. end
  2043. if CurrentModule.LightningBoltEnabled then
  2044. local BoltCFrameTable = {}
  2045. local BoltRadius = CurrentModule.BoltRadius
  2046. for i = 1, CurrentModule.BoltCount do
  2047. if i == 1 then
  2048. table.insert(BoltCFrameTable, CFrame.new(0, 0, 0))
  2049. else
  2050. table.insert(BoltCFrameTable, CFrame.new(math.random(-BoltRadius, BoltRadius), math.random(-BoltRadius, BoltRadius), 0))
  2051. end
  2052. end
  2053. for _, v in ipairs(BoltCFrameTable) do
  2054. local Start = (CFrame.new(FirePoint.WorldPosition, FirePoint.WorldPosition + FireDirection) * v).p
  2055. local End = (CFrame.new(Pos, Pos + FireDirection) * v).p
  2056. local Distance = (End - Start).Magnitude
  2057. local LastPos = Start
  2058. local RandomBoltColor = Color3.new(math.random(), math.random(), math.random())
  2059. for i = 0, Distance, 10 do
  2060. local FakeDistance = CFrame.new(Start, End) * CFrame.new(0, 0, -i - 10) * CFrame.new(-2 + (math.random() * CurrentModule.BoltWideness), -2 + (math.random() * CurrentModule.BoltWideness), -2 + (math.random() * CurrentModule.BoltWideness))
  2061. local BoltSegment = Miscs[CurrentModule.BoltShape.."Segment"]:Clone()
  2062. BoltSegment.CastShadow = false
  2063. BoltSegment.CanQuery = false
  2064. BoltSegment.CanTouch = false
  2065. if CurrentModule.RandomizeBoltColorIn ~= "None" then
  2066. if CurrentModule.RandomizeBoltColorIn == "Whole" then
  2067. BoltSegment.Color = RandomBoltColor
  2068. elseif CurrentModule.RandomizeBoltColorIn == "Segment" then
  2069. BoltSegment.Color = Color3.new(math.random(), math.random(), math.random())
  2070. end
  2071. else
  2072. BoltSegment.Color = CurrentModule.BoltColor
  2073. end
  2074. BoltSegment.Material = CurrentModule.BoltMaterial
  2075. BoltSegment.Reflectance = CurrentModule.BoltReflectance
  2076. BoltSegment.Transparency = CurrentModule.BoltTransparency
  2077. if i + 10 > Distance then
  2078. BoltSegment.CFrame = CFrame.new(LastPos, End) * CFrame.new(0, 0, -(LastPos - End).Magnitude / 2) * (CurrentModule.BoltShape == "Cone" and CFrame.Angles(math.pi / 2, 0, 0) or CFrame.Angles(0, math.pi / 2, 0))
  2079. else
  2080. BoltSegment.CFrame = CFrame.new(LastPos, FakeDistance.p) * CFrame.new(0, 0, -(LastPos - FakeDistance.p).Magnitude / 2) * (CurrentModule.BoltShape == "Cone" and CFrame.Angles(math.pi / 2, 0, 0) or CFrame.Angles(0, math.pi / 2, 0))
  2081. end
  2082. if i + 10 > Distance then
  2083. BoltSegment.Size = CurrentModule.BoltShape == "Cone" and Vector3.new(CurrentModule.BoltWidth, (LastPos - End).Magnitude, CurrentModule.BoltHeight) or Vector3.new((LastPos - End).Magnitude, CurrentModule.BoltHeight, CurrentModule.BoltWidth)
  2084. else
  2085. BoltSegment.Size = CurrentModule.BoltShape == "Cone" and Vector3.new(CurrentModule.BoltWidth, (LastPos - FakeDistance.p).Magnitude, CurrentModule.BoltHeight) or Vector3.new((LastPos - FakeDistance.p).Magnitude, CurrentModule.BoltHeight, CurrentModule.BoltWidth)
  2086. end
  2087. BoltSegment.Parent = Camera
  2088. table.insert(CommonVariables.BoltSegments, BoltSegment)
  2089. Thread:Delay(CurrentModule.BoltVisibleTime, function()
  2090. if CurrentModule.BoltFadeTime > 0 then
  2091. local DesiredSize = BoltSegment.Size * (CurrentModule.ScaleBolt and Vector3.new(1, CurrentModule.BoltScaleMultiplier, CurrentModule.BoltScaleMultiplier) or Vector3.new(1, 1, 1))
  2092. local Tween = TweenService:Create(BoltSegment, TweenInfo.new(CurrentModule.BoltFadeTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Transparency = 1, Size = DesiredSize})
  2093. Tween:Play()
  2094. Tween.Completed:Wait()
  2095. local Index = table.find(CommonVariables.BoltSegments, BoltSegment)
  2096. if Index then
  2097. table.remove(CommonVariables.BoltSegments, Index)
  2098. end
  2099. BoltSegment:Destroy()
  2100. else
  2101. local Index = table.find(CommonVariables.BoltSegments, BoltSegment)
  2102. if Index then
  2103. table.remove(CommonVariables.BoltSegments, Index)
  2104. end
  2105. BoltSegment:Destroy()
  2106. end
  2107. end)
  2108. LastPos = FakeDistance.p
  2109. end
  2110. end
  2111. end
  2112.  
  2113. CrosshairPointAttachment.Parent = Workspace.Terrain
  2114. CrosshairPointAttachment.WorldCFrame = CFrame.new(Pos)
  2115. if CurrentModule.LookAtInput then
  2116. MuzzlePoint.CFrame = MuzzlePoint.Parent.CFrame:toObjectSpace(CFrame.lookAt(MuzzlePoint.WorldPosition, Pos))
  2117. CrosshairPointAttachment.WorldCFrame = CFrame.new(Pos, FireDirection)
  2118. end
  2119.  
  2120. CommonVariables.Misc = {
  2121. ChargeLevel = CurrentVariables.ChargeLevel,
  2122. ModuleName = CurrentModule.ModuleName
  2123. }
  2124.  
  2125. local lastUpdate = CommonVariables.LastUpdate or 0
  2126. local now = os.clock()
  2127. if (now - lastUpdate) > 0.1 then
  2128. CommonVariables.LastUpdate = now
  2129. --Replicate Beam or something
  2130. VisualizeBeam:FireServer(true, {
  2131. Id = GUID,
  2132. Tool = Tool,
  2133. ModuleName = CurrentModule.ModuleName,
  2134. CrosshairPosition = Pos,
  2135. Handle = HandleToFire,
  2136. MuzzlePoint = MuzzlePoint,
  2137. FirePoint = FirePoint,
  2138. })
  2139. end
  2140.  
  2141. local lastUpdate2 = CommonVariables.LastUpdate2 or 0
  2142. local now2 = os.clock()
  2143. if (now2 - lastUpdate2) > CurrentModule.LaserTrailDamageRate then
  2144. CommonVariables.LastUpdate2 = now2
  2145. --Damage hum or something
  2146. if Hit then
  2147. if Hit.Name == "_glass" and CurrentModule.CanBreakGlass then
  2148. ShatterGlass:FireServer(Hit, Pos, FireDirection)
  2149. else
  2150. local Target = Hit:FindFirstAncestorOfClass("Model")
  2151. local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
  2152. local TargetTorso = Target and (Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Head"))
  2153. if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
  2154. Thread:Spawn(function()
  2155. local TempMisc = CloneTable(CommonVariables.Misc)
  2156. TempMisc["ClientHitSize"] = Hit.Size
  2157. InflictTarget:FireServer("GunLaser", Tool, Hit, CreatePacket(TempMisc))
  2158. end)
  2159. MarkHit(CurrentModule)
  2160. end
  2161. end
  2162. end
  2163. if CurrentModule.BatteryEnabled then
  2164. CurrentVariables.ShotsForDepletion = CurrentVariables.ShotsForDepletion + 1
  2165. if CurrentVariables.ShotsForDepletion >= CurrentModule.ShotsForDepletion then
  2166. CurrentVariables.ShotsForDepletion = 0
  2167. UniversalTable.Ammo = math.clamp(UniversalTable.Ammo - Random.new():NextInteger(CurrentModule.MinDepletion, CurrentModule.MaxDepletion), 0, UniversalTable.MaxAmmo)
  2168. end
  2169. CurrentVariables.Heat = math.clamp(CurrentVariables.Heat + Random.new():NextInteger(CurrentModule.HeatPerFireMin, CurrentModule.HeatPerFireMax), 0, CurrentModule.MaxHeat)
  2170. else
  2171. local LastMag = CurrentVariables.Mag
  2172. CurrentVariables.Mag = math.clamp(CurrentVariables.Mag - CurrentModule.AmmoCost, 0, CurrentModule.AmmoPerMag)
  2173. if Module.MagCartridge and not CurrentModule.BatteryEnabled and CurrentModule.AmmoPerMag ~= math.huge then
  2174. for i = 0, (LastMag - CurrentVariables.Mag) - 1 do
  2175. local Bullet = GUI.MagCartridge:FindFirstChild(LastMag - i)
  2176. if Module.Ejection then
  2177. local Vel = Random2DDirection(Module.Velocity, math.random(Module.XMin, Module.XMax), math.random(Module.YMin, Module.YMax)) * (math.random() ^ 0.5)
  2178. CreateCasing(Bullet.Rotation, Bullet.AbsolutePosition, Bullet.AbsoluteSize, Vel, "Shell", Module.Shockwave)
  2179. end
  2180. Bullet.Visible = false
  2181. end
  2182. end
  2183. end
  2184. ChangeMagAndAmmo:FireServer(CurrentFireMode, CurrentVariables.Mag, UniversalTable.Ammo)
  2185. CommonVariables.ShootCounts = CommonVariables.ShootCounts - 1
  2186. if CommonVariables.ShootCounts <= 0 then
  2187. CommonVariables.ShootCounts = CurrentModule.ShootCounts
  2188. end
  2189. CurrentVariables.ShotID = CurrentVariables.ShotID + 1
  2190. local LastShotID = CurrentVariables.ShotID
  2191. Thread:Spawn(function()
  2192. CommonVariables.CanBeCooledDown = false
  2193. local Interrupted = false
  2194. local StartTime = os.clock() repeat Thread:Wait() if LastShotID ~= CurrentVariables.ShotID then break end until (os.clock() - StartTime) >= CurrentModule.TimeBeforeCooldown
  2195. if LastShotID ~= CurrentVariables.ShotID then Interrupted = true end
  2196. if not Interrupted then
  2197. CommonVariables.CanBeCooledDown = true
  2198. end
  2199. end)
  2200. UpdateGUI()
  2201. end
  2202.  
  2203. if CommonVariables.LaserTrail and CurrentModule.DamageableLaserTrail then
  2204. local TouchingParts = Workspace:GetPartsInPart(CommonVariables.LaserTrail, RegionParams)
  2205. for _, part in pairs(TouchingParts) do
  2206. if part and part.Parent then
  2207. local Target = part:FindFirstAncestorOfClass("Model")
  2208. local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
  2209. local TargetTorso = Target and (Target:FindFirstChild("HumanoidRootPart") or part.Parent:FindFirstChild("Head"))
  2210. if TargetHumanoid and TargetHumanoid.Health > 0 and TargetHumanoid.Parent ~= Character and TargetTorso then
  2211. if not table.find(CommonVariables.HitHumanoids, TargetHumanoid) then
  2212. table.insert(CommonVariables.HitHumanoids, TargetHumanoid)
  2213. Thread:Spawn(function()
  2214. local TempMisc = CloneTable(CommonVariables.Misc)
  2215. TempMisc["ClientHitSize"] = part.Size
  2216. InflictTarget:FireServer("GunLaser", Tool, part, CreatePacket(TempMisc))
  2217. end)
  2218. MarkHit(CurrentModule)
  2219. if CurrentModule.LaserTrailConstantDamage then
  2220. Thread:Delay(CurrentModule.LaserTrailDamageRate, function()
  2221. local Index = table.find(CommonVariables.HitHumanoids, TargetHumanoid)
  2222. if Index then
  2223. table.remove(CommonVariables.HitHumanoids, Index)
  2224. end
  2225. end)
  2226. end
  2227. end
  2228. end
  2229. end
  2230. end
  2231. end
  2232.  
  2233. CommonVariables.CurrentRate = CommonVariables.CurrentRate + CurrentModule.SmokeTrailRateIncrement
  2234.  
  2235. Thread:Wait()
  2236. end
  2237. if CommonVariables.Misc then
  2238. VisualizeBeam:FireServer(false, {
  2239. Id = GUID,
  2240. Tool = Tool,
  2241. ModuleName = CurrentModule.ModuleName,
  2242. })
  2243. CommonVariables.Misc = nil
  2244. end
  2245. for i, v in pairs(BeamTable) do
  2246. if v then
  2247. v.Attachment0 = nil
  2248. v.Attachment1 = nil
  2249. v.Parent = nil
  2250. end
  2251. end
  2252. if CommonVariables.LaserTrail then
  2253. Thread:Spawn(function()
  2254. local LastLaserTrail = CommonVariables.LaserTrail
  2255. if CurrentModule.LaserTrailFadeTime > 0 then
  2256. local DesiredSize = LastLaserTrail.Size * (CurrentModule.ScaleLaserTrail and Vector3.new(1, CurrentModule.LaserTrailScaleMultiplier, CurrentModule.LaserTrailScaleMultiplier) or Vector3.new(1, 1, 1))
  2257. local Tween = TweenService:Create(LastLaserTrail, TweenInfo.new(CurrentModule.LaserTrailFadeTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Transparency = 1, Size = DesiredSize})
  2258. Tween:Play()
  2259. Tween.Completed:Wait()
  2260. LastLaserTrail:Destroy()
  2261. else
  2262. LastLaserTrail:Destroy()
  2263. end
  2264. end)
  2265. CommonVariables.LaserTrail = nil
  2266. end
  2267. if CrosshairPointAttachment then
  2268. CrosshairPointAttachment.Parent = nil
  2269. end
  2270. VisibleMuzz(MuzzlePoint, false)
  2271. VisibleMuzzle:FireServer(MuzzlePoint, false)
  2272. if (CurrentModule.BatteryEnabled and CurrentVariables.Heat >= CurrentModule.MaxHeat or CurrentVariables.Mag <= 0) then
  2273. if CommonVariables.CurrentRate >= CurrentModule.MaximumRate and CurrentModule.SmokeTrailEnabled then
  2274. Thread:Spawn(function()
  2275. SmokeTrail:StopEmission()
  2276. SmokeTrail:EmitSmokeTrail(HandleToFire:FindFirstChild("SmokeTrail"..CurrentFireMode), CurrentModule.MaximumTime)
  2277. end)
  2278. end
  2279. end
  2280. if HandleToFire[CurrentFireMode].BeamLoopSound.Playing and HandleToFire[CurrentFireMode].BeamLoopSound.Looped then
  2281. HandleToFire[CurrentFireMode].BeamLoopSound:Stop()
  2282. end
  2283. SetAnimationTrack("LaserBeamLoopAnim", "Stop")
  2284. SetAnimationTrack("LaserBeamStartupAnim", "Stop")
  2285. if HandleToFire[CurrentFireMode].BeamFireSound.Playing then
  2286. HandleToFire[CurrentFireMode].BeamFireSound:Stop()
  2287. end
  2288. if CommonVariables.ActuallyEquipped and HandleToFire[CurrentFireMode]:FindFirstChild("BeamEndSound") then
  2289. HandleToFire[CurrentFireMode].BeamEndSound:Play()
  2290. end
  2291. local Overheated = false
  2292. if CommonVariables.ActuallyEquipped then
  2293. if CurrentModule.BatteryEnabled then
  2294. if CurrentVariables.Heat >= CurrentModule.MaxHeat then
  2295. Overheated = true
  2296. CommonVariables.Enabled = true
  2297. Thread:Spawn(Overheat)
  2298. end
  2299. end
  2300. end
  2301. if not Overheated then
  2302. if CommonVariables.ActuallyEquipped then
  2303. SetAnimationTrack("LaserBeamStopAnim", "Play", CurrentModule.LaserBeamStopAnimationSpeed)
  2304. end
  2305. Thread:Wait(CurrentModule.LaserBeamStopDelay)
  2306. CommonVariables.Enabled = true
  2307. if CommonVariables.ActuallyEquipped and Module.AutoReload and CurrentVariables.Mag <= 0 then
  2308. Reload()
  2309. end
  2310. end
  2311. end
  2312. else
  2313. if CurrentModule.ChargedShotAdvanceEnabled then
  2314. CommonVariables.Charging = true
  2315. if CommonVariables.ActuallyEquipped and CommonVariables.Enabled and CommonVariables.Charging and not CommonVariables.Overheated and not CommonVariables.HoldDown and not CommonVariables.Switching and not CommonVariables.Alting and HasEnoughMag(CurrentModule.AmmoCost) and CurrentVariables.Heat < CurrentModule.MaxHeat and Humanoid.Health > 0 and CanShoot() then
  2316. if Module.CancelReload then
  2317. if CommonVariables.Reloading and not CommonVariables.CanCancelReload then
  2318. CommonVariables.CanCancelReload = true
  2319. end
  2320. else
  2321. if CommonVariables.Reloading then
  2322. return
  2323. end
  2324. end
  2325. CommonVariables.Enabled = false
  2326. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  2327. local ChargingSound = HandleToFire[CurrentFireMode]:FindFirstChild("ChargingSound")
  2328. local StartTime = os.clock()
  2329. local StartTime2
  2330. local Start = false
  2331. local ChargeTime = CurrentModule.AdvancedChargingTime
  2332. if CurrentVariables.ChargeLevelCap == 1 then
  2333. ChargeTime = CurrentModule.Level1ChargingTime
  2334. elseif CurrentVariables.ChargeLevelCap == 2 then
  2335. ChargeTime = CurrentModule.Level2ChargingTime
  2336. end
  2337. while true do
  2338. local DeltaTime = os.clock() - StartTime
  2339. if DeltaTime >= CurrentModule.TimeBeforeAdvancedCharging then
  2340. if not Start then
  2341. Start = true
  2342. StartTime2 = os.clock()
  2343. SetAnimationTrack("ChargingAnim", "Play", CurrentModule.ChargingAnimationSpeed, CurrentModule.ChargingAnimationFadeTime, "IsNotPlaying")
  2344. SetAnimationTrack("AimChargingAnim", "Play", CurrentModule.AimChargingAnimationSpeed, CurrentModule.AimChargingAnimationFadeTime, "IsNotPlaying")
  2345. gunEvent:Fire("VisualizeCharge", CurrentModule.ChargeEffect, "Begin", Character, Tool, HandleToFire, CurrentVariables.ChargeLevel, true)
  2346. end
  2347. local DeltaTime2 = os.clock() - StartTime2
  2348. if CurrentVariables.ChargeLevel == 0 and DeltaTime2 >= CurrentModule.Level1ChargingTime then
  2349. CurrentVariables.ChargeLevel = 1
  2350. SetChargeEffect(CurrentVariables.ChargeLevel, CurrentModule.ChargeEffect)
  2351. elseif CurrentVariables.ChargeLevel == 1 and DeltaTime2 >= CurrentModule.Level2ChargingTime and CurrentVariables.ChargeLevelCap >= 2 then
  2352. CurrentVariables.ChargeLevel = 2
  2353. SetChargeEffect(CurrentVariables.ChargeLevel, CurrentModule.ChargeEffect)
  2354. elseif CurrentVariables.ChargeLevel == 2 and DeltaTime2 >= CurrentModule.AdvancedChargingTime and CurrentVariables.ChargeLevelCap == 3 then
  2355. CurrentVariables.ChargeLevel = 3
  2356. SetChargeEffect(CurrentVariables.ChargeLevel, CurrentModule.ChargeEffect)
  2357. end
  2358. local ChargePercent = math.min(DeltaTime2 / ChargeTime, 1)
  2359. if ChargePercent < 0.5 then --Fade from red to yellow then to green
  2360. GUI.ChargeBar.Fill.BackgroundColor3 = Color3.new(1, ChargePercent * 2, 0)
  2361. else
  2362. GUI.ChargeBar.Fill.BackgroundColor3 = Color3.new(1 - ((ChargePercent - 0.5) / 0.5), 1, 0)
  2363. end
  2364. GUI.ChargeBar.Fill.Size = UDim2.new(ChargePercent, 0, 1, 0)
  2365. if ChargingSound then
  2366. if not ChargingSound.Playing then
  2367. ChargingSound:Play()
  2368. end
  2369. if CurrentModule.ChargingSoundIncreasePitch then
  2370. ChargingSound.PlaybackSpeed = CurrentModule.ChargingSoundPitchRange[1] + (ChargePercent * (CurrentModule.ChargingSoundPitchRange[2] - CurrentModule.ChargingSoundPitchRange[1]))
  2371. end
  2372. end
  2373. end
  2374. Thread:Wait()
  2375. if not CommonVariables.ActuallyEquipped or not CommonVariables.Charging then
  2376. break
  2377. end
  2378. end
  2379. SetAnimationTrack("ChargingAnim", "Stop")
  2380. SetAnimationTrack("AimChargingAnim", "Stop")
  2381. GUI.ChargeBar.Fill.Size = UDim2.new(0, 0, 1, 0)
  2382. if ChargingSound then
  2383. if ChargingSound.Playing then
  2384. ChargingSound:Stop()
  2385. end
  2386. if CurrentModule.ChargingSoundIncreasePitch then
  2387. ChargingSound.PlaybackSpeed = CurrentModule.ChargingSoundPitchRange[1]
  2388. end
  2389. end
  2390. if not CommonVariables.ActuallyEquipped or (not CurrentModule.ShouldFireBeforeCharging and not Start) then
  2391. CurrentVariables.ChargeLevel = 0
  2392. CommonVariables.Enabled = true
  2393. end
  2394. if Start then
  2395. gunEvent:Fire("VisualizeCharge", CurrentModule.ChargeEffect, "End", Character, Tool, HandleToFire, nil, true)
  2396. end
  2397. if (not CurrentModule.ShouldFireBeforeCharging and not Start) then
  2398. return
  2399. end
  2400. if CommonVariables.ActuallyEquipped and not CommonVariables.Enabled and not CommonVariables.Charging and not CommonVariables.Overheated and not CommonVariables.HoldDown and not CommonVariables.Switching and not CommonVariables.Alting and HasEnoughMag(CurrentModule.AmmoCost) and CurrentVariables.Heat < CurrentModule.MaxHeat and Humanoid.Health > 0 and CanShoot() then
  2401. local ModNames
  2402. local TempModule = CloneTable(CurrentModule)
  2403. for j, k in pairs(TempModule.Conditions) do
  2404. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule.MaxHeat, CurrentVariables.Mag, TempModule.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  2405. TempModule = SettingModifier(TempModule, {k})
  2406. if not ModNames then
  2407. ModNames = {}
  2408. end
  2409. if not ModNames["Conditions"] then
  2410. ModNames["Conditions"] = {}
  2411. end
  2412. table.insert(ModNames["Conditions"], j)
  2413. end
  2414. end
  2415. local DidShoot = false
  2416. local Playing = false
  2417. local AudioId = "Audio_"..HttpService:GenerateGUID()
  2418. for i = 1, (TempModule.BurstFireEnabled and AddressTableValue("BulletPerBurst", TempModule) or 1) do
  2419. if not CommonVariables.ActuallyEquipped then
  2420. break
  2421. end
  2422. if ModNames and ModNames["ConditionsInIndividualShot"] then
  2423. ModNames["ConditionsInIndividualShot"] = nil
  2424. end
  2425. local TempModule2 = TempModule
  2426. for j, k in pairs(TempModule2.ConditionsInIndividualShot) do
  2427. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule2.MaxHeat, CurrentVariables.Mag, TempModule2.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  2428. TempModule2 = SettingModifier(TempModule2, {k})
  2429. if not ModNames then
  2430. ModNames = {}
  2431. end
  2432. if not ModNames["ConditionsInIndividualShot"] then
  2433. ModNames["ConditionsInIndividualShot"] = {}
  2434. end
  2435. table.insert(ModNames["ConditionsInIndividualShot"], j)
  2436. end
  2437. end
  2438. if not CanShoot() then
  2439. break
  2440. end
  2441. if TempModule2.BatteryEnabled then
  2442. if CurrentVariables.Heat >= TempModule2.MaxHeat then
  2443. break
  2444. end
  2445. else
  2446. if not HasEnoughMag(TempModule2.AmmoCost) then
  2447. break
  2448. end
  2449. end
  2450. if not Playing then
  2451. Playing = true
  2452. SetFireSoundLoopEnabled(AudioId, true)
  2453. end
  2454. local Directions = {}
  2455. if not TempModule2.ShotgunPump then
  2456. Thread:Spawn(function()
  2457. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= TempModule2.BulletShellDelay
  2458. if CommonVariables.ActuallyEquipped then
  2459. EjectShell(HandleToFire, TempModule2)
  2460. end
  2461. end)
  2462. end
  2463. CommonVariables.CurrentRate = CommonVariables.CurrentRate + TempModule2.SmokeTrailRateIncrement
  2464. local Position = Get3DPosition2()
  2465. if ModNames and ModNames["ConditionsInIndividualBullet"] then
  2466. ModNames["ConditionsInIndividualBullet"] = nil
  2467. end
  2468. for ii = 1, (TempModule2.ShotgunEnabled and AddressTableValue("BulletPerShot", TempModule2) or 1) do
  2469. local BulletId = "Bullet_"..HttpService:GenerateGUID()
  2470. local TempModule3 = TempModule2
  2471. for j, k in pairs(TempModule3.ConditionsInIndividualBullet) do
  2472. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule3.MaxHeat, CurrentVariables.Mag, TempModule3.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  2473. TempModule3 = SettingModifier(TempModule3, {k})
  2474. if not ModNames then
  2475. ModNames = {}
  2476. end
  2477. if not ModNames["ConditionsInIndividualBullet"] then
  2478. ModNames["ConditionsInIndividualBullet"] = {}
  2479. ModNames["ConditionsInIndividualBullet"][BulletId] = {}
  2480. end
  2481. table.insert(ModNames["ConditionsInIndividualBullet"][BulletId], j)
  2482. end
  2483. end
  2484.  
  2485. local Spread = AddressTableValue("Spread", TempModule3)
  2486. local CurrentSpread = Spread * 10 * (CommonVariables.AimDown and 1 - TempModule3.ADSSpreadRedution or 1)
  2487. local cframe = CFrame.new(HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode).WorldPosition, Position)
  2488.  
  2489. local SpreadPattern = AddressTableValue("SpreadPattern", TempModule3)
  2490. if AddressTableValue("ShotgunPattern", TempModule3) and #SpreadPattern > 0 then
  2491. local X, Y = SpreadPattern[ii][1], SpreadPattern[ii][2]
  2492. cframe = cframe * CFrame.Angles(math.rad(CurrentSpread * Y / 50), math.rad(CurrentSpread * X / 50), 0)
  2493. else
  2494. cframe = cframe * CFrame.Angles(math.rad(math.random(-CurrentSpread, CurrentSpread) / 50), math.rad(math.random(-CurrentSpread, CurrentSpread) / 50), 0)
  2495. end
  2496.  
  2497. local Direction = cframe.LookVector
  2498. table.insert(Directions, {Direction, BulletId})
  2499. end
  2500. Fire(HandleToFire, Position, Directions, TempModule2, ModNames)
  2501. if TempModule2.BurstFireEnabled then
  2502. if AddressTableValue("CycleHandles", TempModule2) then
  2503. CycleHandles()
  2504. end
  2505. local BurstRate = AddressTableValue("BurstRate", TempModule2)
  2506. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= BurstRate
  2507. --Thread:Wait(BurstRate)
  2508. end
  2509. DidShoot = true
  2510. end
  2511. if CurrentFireAnim and CurrentFireAnim.Looped then
  2512. SetAnimationTrack("FireAnim", "Stop")
  2513. end
  2514. if CurrentAimFireAnim and CurrentAimFireAnim.Looped then
  2515. SetAnimationTrack("AimFireAnim", "Stop")
  2516. end
  2517. if Playing then
  2518. Playing = false
  2519. SetFireSoundLoopEnabled(AudioId, false)
  2520. end
  2521. if DidShoot and not TempModule.ShotgunPump and not (TempModule.BurstFireEnabled and AddressTableValue("CycleHandles", TempModule)) then
  2522. CycleHandles()
  2523. end
  2524. if (TempModule.BatteryEnabled and CurrentVariables.Heat >= TempModule.MaxHeat or CurrentVariables.Mag <= 0) then
  2525. if CommonVariables.CurrentRate >= TempModule.MaximumRate and TempModule.SmokeTrailEnabled then
  2526. Thread:Spawn(function()
  2527. SmokeTrail:StopEmission()
  2528. SmokeTrail:EmitSmokeTrail(HandleToFire:FindFirstChild("SmokeTrail"..CurrentFireMode), TempModule.MaximumTime)
  2529. end)
  2530. end
  2531. end
  2532. local Overheated = false
  2533. if CommonVariables.ActuallyEquipped then
  2534. if TempModule.BatteryEnabled then
  2535. if CurrentVariables.Heat >= TempModule.MaxHeat then
  2536. Overheated = true
  2537. CurrentVariables.ChargeLevel = 0
  2538. CommonVariables.Enabled = true
  2539. Thread:Spawn(Overheat)
  2540. end
  2541. end
  2542. end
  2543. if not Overheated then
  2544. if DidShoot then
  2545. Thread:Wait(AddressTableValue("FireRate", TempModule))
  2546. if TempModule.ShotgunPump then
  2547. if CommonVariables.ActuallyEquipped then
  2548. SetAnimationTrack("ShotgunPumpinAnim", "Play", CurrentShotgunPumpinAnimationSpeed)
  2549. if HandleToFire[CurrentFireMode]:FindFirstChild("PumpSound") then
  2550. HandleToFire[CurrentFireMode].PumpSound:Play()
  2551. end
  2552. Thread:Spawn(function()
  2553. local StartTime = os.clock() repeat Thread:Wait() if not CurrentVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= TempModule.BulletShellDelay
  2554. if CurrentVariables.ActuallyEquipped then
  2555. EjectShell(HandleToFire, TempModule)
  2556. end
  2557. end)
  2558. end
  2559. if not (TempModule.BurstFireEnabled and AddressTableValue("CycleHandles", TempModule)) then
  2560. CycleHandles()
  2561. end
  2562. Thread:Wait(TempModule.ShotgunPumpinSpeed)
  2563. end
  2564. end
  2565. CurrentVariables.ChargeLevel = 0
  2566. CommonVariables.Enabled = true
  2567. if CommonVariables.ActuallyEquipped and Module.AutoReload and CurrentVariables.Mag <= 0 then
  2568. Reload()
  2569. end
  2570. end
  2571. end
  2572. end
  2573. elseif CurrentModule.HoldAndReleaseEnabled and not CurrentModule.SelectiveFireEnabled then
  2574. CommonVariables.Charging = true
  2575. if CommonVariables.ActuallyEquipped and CommonVariables.Enabled and CommonVariables.Charging and not CommonVariables.Overheated and not CommonVariables.HoldDown and not CommonVariables.Switching and not CommonVariables.Alting and HasEnoughMag(CurrentModule.AmmoCost) and CurrentVariables.Heat < CurrentModule.MaxHeat and Humanoid.Health > 0 and CanShoot() then
  2576. if Module.CancelReload then
  2577. if CommonVariables.Reloading and not CommonVariables.CanCancelReload then
  2578. CommonVariables.CanCancelReload = true
  2579. end
  2580. else
  2581. if CommonVariables.Reloading then
  2582. return
  2583. end
  2584. end
  2585. CommonVariables.Enabled = false
  2586. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  2587. local ChargingSound = HandleToFire[CurrentFireMode]:FindFirstChild("ChargingSound")
  2588. local StartTime = os.clock()
  2589. local StartTime2
  2590. local Start = false
  2591. local LockedOnTargets = {}
  2592. local TargetCounts = 0
  2593. local ScanInterval = CurrentModule.ScanRate
  2594. while true do
  2595. if not CurrentModule.LockOnScan then
  2596. local DeltaTime = os.clock() - StartTime
  2597. if DeltaTime >= CurrentModule.TimeBeforeHolding then
  2598. if not Start then
  2599. Start = true
  2600. StartTime2 = os.clock()
  2601. SetAnimationTrack("ChargingAnim", "Play", CurrentModule.ChargingAnimationSpeed, CurrentModule.ChargingAnimationFadeTime, "IsNotPlaying")
  2602. SetAnimationTrack("AimChargingAnim", "Play", CurrentModule.AimChargingAnimationSpeed, CurrentModule.AimChargingAnimationFadeTime, "IsNotPlaying")
  2603. gunEvent:Fire("VisualizeCharge", CurrentModule.HoldChargeEffect, "Begin", Character, Tool, HandleToFire, 0, true)
  2604. end
  2605. local DeltaTime2 = os.clock() - StartTime2
  2606. if not CommonVariables.Charged and DeltaTime2 >= CurrentModule.HoldingTime then
  2607. CommonVariables.Charged = true
  2608. SetChargeEffect(3, CurrentModule.HoldChargeEffect)
  2609. end
  2610. local ChargePercent = math.min(DeltaTime2 / CurrentModule.HoldingTime, 1)
  2611. if ChargePercent < 0.5 then --Fade from red to yellow then to green
  2612. GUI.ChargeBar.Fill.BackgroundColor3 = Color3.new(1, ChargePercent * 2, 0)
  2613. else
  2614. GUI.ChargeBar.Fill.BackgroundColor3 = Color3.new(1 - ((ChargePercent - 0.5) / 0.5), 1, 0)
  2615. end
  2616. GUI.ChargeBar.Fill.Size = UDim2.new(ChargePercent, 0, 1, 0)
  2617. if ChargingSound then
  2618. if not ChargingSound.Playing then
  2619. ChargingSound:Play()
  2620. end
  2621. if CurrentModule.ChargingSoundIncreasePitch then
  2622. ChargingSound.PlaybackSpeed = CurrentModule.ChargingSoundPitchRange[1] + (ChargePercent * (CurrentModule.ChargingSoundPitchRange[2] - CurrentModule.ChargingSoundPitchRange[1]))
  2623. end
  2624. end
  2625. end
  2626. else
  2627. CommonVariables.Charged = true
  2628. local DeltaTime = os.clock() - StartTime
  2629. if DeltaTime >= CurrentModule.TimeBeforeScan then
  2630. if not Start then
  2631. Start = true
  2632. StartTime2 = os.clock()
  2633. CurrentModule.OnScannerToggle(CommonVariables.Radar, CurrentModule.MaximumTargets, true)
  2634. end
  2635. local DeltaTime2 = os.clock() - StartTime2
  2636. if DeltaTime2 >= ScanInterval then
  2637. StartTime2 = os.clock()
  2638. local TargetEntity, TargetHumanoid, TargetTorso, AlreadyLocked = FindNearestEntity(LockedOnTargets)
  2639. if TargetEntity and TargetHumanoid and TargetTorso then
  2640. if TargetCounts < CurrentModule.MaximumTargets then
  2641. TargetCounts = TargetCounts + 1
  2642. if AlreadyLocked then
  2643. ScanInterval = CurrentModule.ScanRateOnLockedTarget
  2644. else
  2645. ScanInterval = CurrentModule.ScanRate
  2646. end
  2647. CurrentModule.OnScannerUpdate(CommonVariables.Radar, TargetCounts, CurrentModule.MaximumTargets, AlreadyLocked, true)
  2648. local TargetMarkerClone = Scanners.Markers[CurrentModule.Marker]:Clone()
  2649. TargetMarkerClone.Name = "TargetMarker"
  2650. TargetMarkerClone.Parent = GUI
  2651. TargetMarkerClone.Adornee = TargetTorso
  2652. TargetMarkerClone.Enabled = true
  2653. CurrentModule.OnTrackingTarget(TargetMarkerClone)
  2654. table.insert(LockedOnTargets, {TargetEntity = TargetEntity, TargetTorso = TargetTorso, TargetMarker = TargetMarkerClone})
  2655. end
  2656. end
  2657. end
  2658. if CurrentModule.RemoveTargetsWhenOutbound then
  2659. for i = #LockedOnTargets, 1, -1 do
  2660. if LockedOnTargets[i].TargetEntity and LockedOnTargets[i].TargetTorso then
  2661. if not CheckPartInScanner(LockedOnTargets[i].TargetTorso) then
  2662. TargetCounts = TargetCounts - 1
  2663. CurrentModule.OnScannerUpdate(CommonVariables.Radar, TargetCounts, CurrentModule.MaximumTargets)
  2664. if LockedOnTargets[i].TargetMarker then
  2665. LockedOnTargets[i].TargetMarker:Destroy()
  2666. end
  2667. table.remove(LockedOnTargets, i)
  2668. end
  2669. else
  2670. TargetCounts = TargetCounts - 1
  2671. CurrentModule.OnScannerUpdate(CommonVariables.Radar, TargetCounts, CurrentModule.MaximumTargets)
  2672. if LockedOnTargets[i].TargetMarker then
  2673. LockedOnTargets[i].TargetMarker:Destroy()
  2674. end
  2675. table.remove(LockedOnTargets, i)
  2676. end
  2677. end
  2678. end
  2679. end
  2680. end
  2681. Thread:Wait()
  2682. if not CommonVariables.ActuallyEquipped or not CommonVariables.Charging then
  2683. break
  2684. end
  2685. end
  2686. SetAnimationTrack("ChargingAnim", "Stop")
  2687. SetAnimationTrack("AimChargingAnim", "Stop")
  2688. if not CurrentModule.LockOnScan then
  2689. GUI.ChargeBar.Fill.Size = UDim2.new(0, 0, 1, 0)
  2690. if ChargingSound then
  2691. if ChargingSound.Playing then
  2692. ChargingSound:Stop()
  2693. end
  2694. if CurrentModule.ChargingSoundIncreasePitch then
  2695. ChargingSound.PlaybackSpeed = CurrentModule.ChargingSoundPitchRange[1]
  2696. end
  2697. end
  2698. if Start then
  2699. gunEvent:Fire("VisualizeCharge", CurrentModule.HoldChargeEffect, "End", Character, Tool, HandleToFire, nil, true)
  2700. end
  2701. else
  2702. if CommonVariables.Radar then
  2703. CurrentModule.OnScannerToggle(CommonVariables.Radar, CurrentModule.MaximumTargets, false)
  2704. end
  2705. for i, v in pairs(LockedOnTargets) do
  2706. if v.TargetMarker then
  2707. v.TargetMarker:Destroy()
  2708. end
  2709. end
  2710. end
  2711. if not CommonVariables.ActuallyEquipped or (CurrentModule.ShouldFireWhenTheresTarget and #LockedOnTargets <= 0) then
  2712. CommonVariables.Charged = false
  2713. CommonVariables.Enabled = true
  2714. end
  2715. if (CurrentModule.ShouldFireWhenTheresTarget and #LockedOnTargets <= 0) then
  2716. return
  2717. end
  2718. if CommonVariables.ActuallyEquipped and not CommonVariables.Enabled and not CommonVariables.Charging and CommonVariables.Charged and not CommonVariables.Overheated and not CommonVariables.HoldDown and not CommonVariables.Switching and not CommonVariables.Alting and HasEnoughMag(CurrentModule.AmmoCost) and CurrentVariables.Heat < CurrentModule.MaxHeat and Humanoid.Health > 0 and CanShoot() then
  2719. CommonVariables.Charged = false
  2720. local ModNames
  2721. local TempModule = CloneTable(CurrentModule)
  2722. for j, k in pairs(TempModule.Conditions) do
  2723. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule.MaxHeat, CurrentVariables.Mag, TempModule.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  2724. TempModule = SettingModifier(TempModule, {k})
  2725. if not ModNames then
  2726. ModNames = {}
  2727. end
  2728. if not ModNames["Conditions"] then
  2729. ModNames["Conditions"] = {}
  2730. end
  2731. table.insert(ModNames["Conditions"], j)
  2732. end
  2733. end
  2734. local DidShoot = false
  2735. local Playing = false
  2736. local AudioId = "Audio_"..HttpService:GenerateGUID()
  2737. for i = 1, TempModule.LockOnScan and (TargetCounts > 0 and TargetCounts or 1) or (TempModule.BurstFireEnabled and TempModule.BulletPerBurst or 1) do
  2738. if not CommonVariables.ActuallyEquipped then
  2739. break
  2740. end
  2741. if ModNames and ModNames["ConditionsInIndividualShot"] then
  2742. ModNames["ConditionsInIndividualShot"] = nil
  2743. end
  2744. local TempModule2 = TempModule
  2745. for j, k in pairs(TempModule2.ConditionsInIndividualShot) do
  2746. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule2.MaxHeat, CurrentVariables.Mag, TempModule2.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  2747. TempModule2 = SettingModifier(TempModule2, {k})
  2748. if not ModNames then
  2749. ModNames = {}
  2750. end
  2751. if not ModNames["ConditionsInIndividualShot"] then
  2752. ModNames["ConditionsInIndividualShot"] = {}
  2753. end
  2754. table.insert(ModNames["ConditionsInIndividualShot"], j)
  2755. end
  2756. end
  2757. if not CanShoot() then
  2758. break
  2759. end
  2760. if TempModule2.BatteryEnabled then
  2761. if CurrentVariables.Heat >= TempModule2.MaxHeat then
  2762. break
  2763. end
  2764. else
  2765. if not HasEnoughMag(TempModule2.AmmoCost) then
  2766. break
  2767. end
  2768. end
  2769. if not Playing then
  2770. Playing = true
  2771. SetFireSoundLoopEnabled(AudioId, true)
  2772. end
  2773. local FirstShot
  2774. if TempModule2.LockOnScan and TempModule2.InstaBurst and i == 1 then
  2775. FirstShot = true
  2776. end
  2777. local Directions = {}
  2778. if not TempModule2.ShotgunPump then
  2779. Thread:Spawn(function()
  2780. local CanEject = true
  2781. if TempModule2.LockOnScan and TempModule2.InstaBurst then
  2782. CanEject = (i == 1)
  2783. end
  2784. if not CanEject then
  2785. return
  2786. end
  2787. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= TempModule2.BulletShellDelay
  2788. if CommonVariables.ActuallyEquipped then
  2789. EjectShell(HandleToFire, TempModule2)
  2790. end
  2791. end)
  2792. end
  2793. CommonVariables.CurrentRate = CommonVariables.CurrentRate + TempModule2.SmokeTrailRateIncrement
  2794. local Position = (TempModule2.LockOnScan and #LockedOnTargets > 0) and (LockedOnTargets[i].TargetTorso and LockedOnTargets[i].TargetTorso.Position or Get3DPosition2()) or Get3DPosition2()
  2795. if ModNames and ModNames["ConditionsInIndividualBullet"] then
  2796. ModNames["ConditionsInIndividualBullet"] = nil
  2797. end
  2798. for ii = 1, (TempModule2.ShotgunEnabled and TempModule2.BulletPerShot or 1) do
  2799. local BulletId = "Bullet_"..HttpService:GenerateGUID()
  2800. local TempModule3 = TempModule2
  2801. for j, k in pairs(TempModule3.ConditionsInIndividualBullet) do
  2802. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule3.MaxHeat, CurrentVariables.Mag, TempModule3.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  2803. TempModule3 = SettingModifier(TempModule3, {k})
  2804. if not ModNames then
  2805. ModNames = {}
  2806. end
  2807. if not ModNames["ConditionsInIndividualBullet"] then
  2808. ModNames["ConditionsInIndividualBullet"] = {}
  2809. ModNames["ConditionsInIndividualBullet"][BulletId] = {}
  2810. end
  2811. table.insert(ModNames["ConditionsInIndividualBullet"][BulletId], j)
  2812. end
  2813. end
  2814.  
  2815. local Spread = TempModule3.Spread * 10 * (CommonVariables.AimDown and 1 - TempModule3.ADSSpreadRedution or 1)
  2816. local cframe = CFrame.new(HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode).WorldPosition, Position)
  2817.  
  2818. if TempModule3.ShotgunPattern and #TempModule3.SpreadPattern > 0 then
  2819. local X, Y = TempModule3.SpreadPattern[ii][1], TempModule3.SpreadPattern[ii][2]
  2820. cframe = cframe * CFrame.Angles(math.rad(Spread * Y / 50), math.rad(Spread * X / 50), 0)
  2821. else
  2822. cframe = cframe * CFrame.Angles(math.rad(math.random(-Spread, Spread) / 50), math.rad(math.random(-Spread, Spread) / 50), 0)
  2823. end
  2824.  
  2825. local Direction = cframe.LookVector
  2826. table.insert(Directions, {Direction, BulletId})
  2827. end
  2828. Fire(HandleToFire, Position, Directions, TempModule2, ModNames, (TempModule2.LockOnScan and #LockedOnTargets > 0) and (LockedOnTargets[i].TargetEntity or nil) or nil, FirstShot)
  2829. if TempModule2.LockOnScan then
  2830. local CanCycle = true
  2831. if TempModule2.InstaBurst and TempModule2.TriggerOnce then
  2832. CanCycle = (i == 1)
  2833. end
  2834. if TempModule2.CycleHandles and CanCycle then
  2835. CycleHandles()
  2836. end
  2837. if not TempModule2.InstaBurst then
  2838. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= TempModule2.LockOnScanBurstRate
  2839. --Thread:Wait(TempModule2.LockOnScanBurstRate)
  2840. end
  2841. else
  2842. if TempModule2.BurstFireEnabled then
  2843. if TempModule2.CycleHandles then
  2844. CycleHandles()
  2845. end
  2846. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= TempModule2.BurstRate
  2847. --Thread:Wait(TempModule2.BurstRate)
  2848. end
  2849. end
  2850. DidShoot = true
  2851. end
  2852. if CurrentFireAnim and CurrentFireAnim.Looped then
  2853. SetAnimationTrack("FireAnim", "Stop")
  2854. end
  2855. if CurrentAimFireAnim and CurrentAimFireAnim.Looped then
  2856. SetAnimationTrack("AimFireAnim", "Stop")
  2857. end
  2858. if Playing then
  2859. Playing = false
  2860. SetFireSoundLoopEnabled(AudioId, false)
  2861. end
  2862. if DidShoot and not TempModule.ShotgunPump and not ((TempModule.LockOnScan or TempModule.BurstFireEnabled) and TempModule.CycleHandles) then
  2863. CycleHandles()
  2864. end
  2865. if (TempModule.BatteryEnabled and CurrentVariables.Heat >= TempModule.MaxHeat or CurrentVariables.Mag <= 0) then
  2866. if CommonVariables.CurrentRate >= TempModule.MaximumRate and TempModule.SmokeTrailEnabled then
  2867. Thread:Spawn(function()
  2868. SmokeTrail:StopEmission()
  2869. SmokeTrail:EmitSmokeTrail(HandleToFire:FindFirstChild("SmokeTrail"..CurrentFireMode), TempModule.MaximumTime)
  2870. end)
  2871. end
  2872. end
  2873. local Overheated = false
  2874. if CommonVariables.ActuallyEquipped then
  2875. if TempModule.BatteryEnabled then
  2876. if CurrentVariables.Heat >= TempModule.MaxHeat then
  2877. Overheated = true
  2878. CommonVariables.Enabled = true
  2879. Thread:Spawn(Overheat)
  2880. end
  2881. end
  2882. end
  2883. if not Overheated then
  2884. if DidShoot then
  2885. Thread:Wait(TempModule.FireRate)
  2886. if TempModule.ShotgunPump then
  2887. if CommonVariables.ActuallyEquipped then
  2888. SetAnimationTrack("ShotgunPumpinAnim", "Play", CurrentShotgunPumpinAnimationSpeed)
  2889. if HandleToFire[CurrentFireMode]:FindFirstChild("PumpSound") then
  2890. HandleToFire[CurrentFireMode].PumpSound:Play()
  2891. end
  2892. Thread:Spawn(function()
  2893. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= TempModule.BulletShellDelay
  2894. if CommonVariables.ActuallyEquipped then
  2895. EjectShell(HandleToFire, TempModule)
  2896. end
  2897. end)
  2898. end
  2899. if not ((TempModule.LockOnScan or TempModule.BurstFireEnabled) and TempModule.CycleHandles) then
  2900. CycleHandles()
  2901. end
  2902. Thread:Wait(TempModule.ShotgunPumpinSpeed)
  2903. end
  2904. end
  2905. CommonVariables.Enabled = true
  2906. if CommonVariables.ActuallyEquipped and Module.AutoReload and CurrentVariables.Mag <= 0 then
  2907. Reload()
  2908. end
  2909. end
  2910. end
  2911. end
  2912. else
  2913. CommonVariables.Down = true
  2914. if CommonVariables.ActuallyEquipped and CommonVariables.Enabled and CommonVariables.Down and not CommonVariables.Overheated and not CommonVariables.HoldDown and not CommonVariables.Switching and not CommonVariables.Alting and HasEnoughMag(CurrentModule.AmmoCost) and CurrentVariables.Heat < CurrentModule.MaxHeat and Humanoid.Health > 0 and CanShoot() then
  2915. if Module.CancelReload then
  2916. if CommonVariables.Reloading and not CommonVariables.CanCancelReload then
  2917. CommonVariables.CanCancelReload = true
  2918. end
  2919. else
  2920. if CommonVariables.Reloading then
  2921. return
  2922. end
  2923. end
  2924. CommonVariables.Enabled = false
  2925. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  2926. if CurrentModule.MinigunEnabled then
  2927. SetAnimationTrack("MinigunRevUpAnim", "Play", CurrentModule.MinigunRevUpAnimationSpeed)
  2928. if CommonVariables.ActuallyEquipped and HandleToFire[CurrentFireMode]:FindFirstChild("WindUp") then
  2929. HandleToFire[CurrentFireMode].WindUp:Play()
  2930. end
  2931. local Interrupted = false
  2932. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then Interrupted = true break end until (os.clock() - StartTime) >= CurrentModule.DelayBeforeFiring
  2933. if Interrupted then
  2934. SetAnimationTrack("MinigunRevUpAnim", "Stop")
  2935. if HandleToFire[CurrentFireMode]:FindFirstChild("WindUp") then
  2936. HandleToFire[CurrentFireMode].WindUp:Stop()
  2937. end
  2938. end
  2939. --Thread:Wait(CurrentModule.DelayBeforeFiring)
  2940. end
  2941. CommonVariables.CurrentFireRate = CurrentModule.FireRate
  2942. local DidShoot = false
  2943. local Playing = false
  2944. local AudioId = "Audio_"..HttpService:GenerateGUID()
  2945. while CommonVariables.ActuallyEquipped and not CommonVariables.Overheated and CommonVariables.Down and not CommonVariables.HoldDown and not CommonVariables.Switching and not CommonVariables.Alting and HasEnoughMag(CurrentModule.AmmoCost) and CurrentVariables.Heat < CurrentModule.MaxHeat and Humanoid.Health > 0 and CanShoot() do
  2946. local IsChargedShot = false
  2947. if CurrentModule.ChargedShotEnabled then
  2948. if CommonVariables.ActuallyEquipped and HandleToFire[CurrentFireMode]:FindFirstChild("ChargeSound") then
  2949. HandleToFire[CurrentFireMode].ChargeSound:Play()
  2950. end
  2951. local Interrupted = false
  2952. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then Interrupted = true break end until (os.clock() - StartTime) >= CurrentModule.ChargingTime
  2953. if Interrupted then
  2954. if HandleToFire[CurrentFireMode]:FindFirstChild("ChargeSound") then
  2955. HandleToFire[CurrentFireMode].ChargeSound:Stop()
  2956. end
  2957. else
  2958. IsChargedShot = true
  2959. end
  2960. --Thread:Wait(CurrentModule.ChargingTime)
  2961. if not IsChargedShot then
  2962. break
  2963. end
  2964. end
  2965. local ModNames
  2966. local TempModule = CloneTable(CurrentModule)
  2967. for j, k in pairs(TempModule.Conditions) do
  2968. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule.MaxHeat, CurrentVariables.Mag, TempModule.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  2969. TempModule = SettingModifier(TempModule, {k})
  2970. if not ModNames then
  2971. ModNames = {}
  2972. end
  2973. if not ModNames["Conditions"] then
  2974. ModNames["Conditions"] = {}
  2975. end
  2976. table.insert(ModNames["Conditions"], j)
  2977. end
  2978. end
  2979. for i = 1, ((TempModule.SelectiveFireEnabled and (CurrentVariables.FireModes[CurrentVariables.FireMode] ~= true and CurrentVariables.FireModes[CurrentVariables.FireMode] or 1)) or (TempModule.BurstFireEnabled and TempModule.BulletPerBurst) or 1) do
  2980. if not CommonVariables.ActuallyEquipped then
  2981. break
  2982. end
  2983. if ModNames and ModNames["ConditionsInIndividualShot"] then
  2984. ModNames["ConditionsInIndividualShot"] = nil
  2985. end
  2986. local TempModule2 = TempModule
  2987. for j, k in pairs(TempModule2.ConditionsInIndividualShot) do
  2988. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule2.MaxHeat, CurrentVariables.Mag, TempModule2.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  2989. TempModule2 = SettingModifier(TempModule2, {k})
  2990. if not ModNames then
  2991. ModNames = {}
  2992. end
  2993. if not ModNames["ConditionsInIndividualShot"] then
  2994. ModNames["ConditionsInIndividualShot"] = {}
  2995. end
  2996. table.insert(ModNames["ConditionsInIndividualShot"], j)
  2997. end
  2998. end
  2999. if not CanShoot() then
  3000. break
  3001. end
  3002. if TempModule2.BatteryEnabled then
  3003. if CurrentVariables.Heat >= TempModule2.MaxHeat then
  3004. break
  3005. end
  3006. else
  3007. if not HasEnoughMag(TempModule2.AmmoCost) then
  3008. break
  3009. end
  3010. end
  3011. if not Playing then
  3012. Playing = true
  3013. SetFireSoundLoopEnabled(AudioId, true)
  3014. end
  3015. local Directions = {}
  3016. if not TempModule2.ShotgunPump then
  3017. Thread:Spawn(function()
  3018. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= TempModule2.BulletShellDelay
  3019. if CommonVariables.ActuallyEquipped then
  3020. EjectShell(HandleToFire, TempModule2)
  3021. end
  3022. end)
  3023. end
  3024. CommonVariables.CurrentRate = CommonVariables.CurrentRate + TempModule2.SmokeTrailRateIncrement
  3025. local Position = Get3DPosition2()
  3026. if ModNames and ModNames["ConditionsInIndividualBullet"] then
  3027. ModNames["ConditionsInIndividualBullet"] = nil
  3028. end
  3029. for ii = 1, (TempModule2.ShotgunEnabled and TempModule2.BulletPerShot or 1) do
  3030. local BulletId = "Bullet_"..HttpService:GenerateGUID()
  3031. local TempModule3 = TempModule2
  3032. for j, k in pairs(TempModule3.ConditionsInIndividualBullet) do
  3033. if ConditionableGunMods[j] and ConditionableGunMods[j](Tool, Humanoid, CurrentVariables.Heat, TempModule3.MaxHeat, CurrentVariables.Mag, TempModule3.AmmoPerMag, UniversalTable.Ammo, UniversalTable.MaxAmmo, CommonVariables.ShootCounts, CommonVariables.CurrentFireRate) then
  3034. TempModule3 = SettingModifier(TempModule3, {k})
  3035. if not ModNames then
  3036. ModNames = {}
  3037. end
  3038. if not ModNames["ConditionsInIndividualBullet"] then
  3039. ModNames["ConditionsInIndividualBullet"] = {}
  3040. ModNames["ConditionsInIndividualBullet"][BulletId] = {}
  3041. end
  3042. table.insert(ModNames["ConditionsInIndividualBullet"][BulletId], j)
  3043. end
  3044. end
  3045.  
  3046. local Spread = TempModule3.Spread * 10 * (CommonVariables.AimDown and 1 - TempModule3.ADSSpreadRedution or 1)
  3047. local cframe = CFrame.new(HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode).WorldPosition, Position)
  3048.  
  3049. if TempModule3.ShotgunPattern and #TempModule3.SpreadPattern > 0 then
  3050. local X, Y = TempModule3.SpreadPattern[ii][1], TempModule3.SpreadPattern[ii][2]
  3051. cframe = cframe * CFrame.Angles(math.rad(Spread * Y / 50), math.rad(Spread * X / 50), 0)
  3052. else
  3053. cframe = cframe * CFrame.Angles(math.rad(math.random(-Spread, Spread) / 50), math.rad(math.random(-Spread, Spread) / 50), 0)
  3054. end
  3055.  
  3056. local Direction = cframe.LookVector
  3057. table.insert(Directions, {Direction, BulletId})
  3058. end
  3059. Fire(HandleToFire, Position, Directions, TempModule2, ModNames)
  3060. if TempModule2.BurstFireEnabled or TempModule2.SelectiveFireEnabled then
  3061. if TempModule2.CycleHandles then
  3062. CycleHandles()
  3063. end
  3064. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= (TempModule2.SelectiveFireEnabled and TempModule2.BurstRates[CurrentVariables.FireMode] or TempModule2.BurstRate)
  3065. --Thread:Wait(TempModule2.SelectiveFireEnabled and TempModule2.BurstRates[CurrentVariables.FireMode] or TempModule2.BurstRate)
  3066. end
  3067. DidShoot = true
  3068. end
  3069. if DidShoot and not TempModule.ShotgunPump and not ((TempModule.SelectiveFireEnabled or TempModule.BurstFireEnabled) and TempModule.CycleHandles) then
  3070. CycleHandles()
  3071. end
  3072. if (TempModule.BatteryEnabled and CurrentVariables.Heat >= TempModule.MaxHeat or CurrentVariables.Mag <= 0) then
  3073. if CommonVariables.CurrentRate >= TempModule.MaximumRate and TempModule.SmokeTrailEnabled then
  3074. Thread:Spawn(function()
  3075. SmokeTrail:StopEmission()
  3076. SmokeTrail:EmitSmokeTrail(HandleToFire:FindFirstChild("SmokeTrail"..CurrentFireMode), TempModule.MaximumTime)
  3077. end)
  3078. end
  3079. end
  3080. if TempModule.BatteryEnabled then
  3081. if CurrentVariables.Heat >= TempModule.MaxHeat then
  3082. break
  3083. end
  3084. end
  3085. if DidShoot then
  3086. Thread:Wait(TempModule.SelectiveFireEnabled and TempModule.FireRates[CurrentVariables.FireMode] or ((TempModule.Auto and TempModule.GainFireRateAsAutoFire) and CommonVariables.CurrentFireRate or TempModule.FireRate))
  3087. if TempModule.SelectiveFireEnabled then
  3088. if CurrentVariables.FireModes[CurrentVariables.FireMode] ~= true then
  3089. break
  3090. end
  3091. else
  3092. if not TempModule.Auto then
  3093. break
  3094. else
  3095. if TempModule.GainFireRateAsAutoFire then
  3096. CommonVariables.CurrentFireRate = math.clamp(CommonVariables.CurrentFireRate - TempModule.FireRateIncrement, TempModule.MaximumFireRate, TempModule.FireRate)
  3097. end
  3098. end
  3099. end
  3100. else
  3101. break
  3102. end
  3103. end
  3104. if CurrentFireAnim and CurrentFireAnim.Looped then
  3105. SetAnimationTrack("FireAnim", "Stop")
  3106. end
  3107. if CurrentAimFireAnim and CurrentAimFireAnim.Looped then
  3108. SetAnimationTrack("AimFireAnim", "Stop")
  3109. end
  3110. if Playing then
  3111. Playing = false
  3112. SetFireSoundLoopEnabled(AudioId, false)
  3113. end
  3114. if CurrentModule.MinigunEnabled and CommonVariables.ActuallyEquipped and HandleToFire[CurrentFireMode]:FindFirstChild("WindDown") then
  3115. HandleToFire[CurrentFireMode].WindDown:Play()
  3116. end
  3117. local Overheated = false
  3118. if CommonVariables.ActuallyEquipped then
  3119. if CurrentModule.BatteryEnabled then
  3120. if CurrentVariables.Heat >= CurrentModule.MaxHeat then
  3121. Overheated = true
  3122. CommonVariables.Enabled = true
  3123. Thread:Spawn(Overheat)
  3124. end
  3125. end
  3126. end
  3127. if not Overheated then
  3128. if CurrentModule.MinigunEnabled then
  3129. if CommonVariables.ActuallyEquipped then
  3130. SetAnimationTrack("MinigunRevDownAnim", "Play", CurrentModule.MinigunRevDownAnimationSpeed)
  3131. end
  3132. SetAnimationTrack("MinigunRevUpAnim", "Stop")
  3133. Thread:Wait(CurrentModule.DelayAfterFiring)
  3134. end
  3135. if DidShoot then
  3136. if CurrentModule.ShotgunPump then
  3137. if CommonVariables.ActuallyEquipped then
  3138. SetAnimationTrack("ShotgunPumpinAnim", "Play", CurrentShotgunPumpinAnimationSpeed)
  3139. if HandleToFire[CurrentFireMode]:FindFirstChild("PumpSound") then
  3140. HandleToFire[CurrentFireMode].PumpSound:Play()
  3141. end
  3142. Thread:Spawn(function()
  3143. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.ActuallyEquipped then break end until (os.clock() - StartTime) >= CurrentModule.BulletShellDelay
  3144. if CommonVariables.ActuallyEquipped then
  3145. EjectShell(HandleToFire, CurrentModule)
  3146. end
  3147. end)
  3148. end
  3149. if not (CurrentModule.BurstFireEnabled and CurrentModule.CycleHandles) then
  3150. CycleHandles()
  3151. end
  3152. Thread:Wait(CurrentModule.ShotgunPumpinSpeed)
  3153. end
  3154. end
  3155. CommonVariables.Enabled = true
  3156. if CommonVariables.ActuallyEquipped and Module.AutoReload and CurrentVariables.Mag <= 0 then
  3157. Reload()
  3158. end
  3159. end
  3160. end
  3161. end
  3162. end
  3163. end
  3164.  
  3165. function OnStoppingFiring()
  3166. CommonVariables.Down = false
  3167. if CurrentModule.ChargedShotAdvanceEnabled or CurrentModule.HoldAndReleaseEnabled then
  3168. CommonVariables.Charging = false
  3169. end
  3170. if CurrentModule.HoldAndReleaseEnabled and not CommonVariables.Charged then
  3171. CommonVariables.Enabled = true
  3172. end
  3173. end
  3174.  
  3175. function OnMeleeHit(Hit, RegionalHitbox, RaycastHitboxTable)
  3176. if Hit.Name == "_glass" and CurrentModule.MeleeCanBreakGlass then
  3177. if not CommonVariables.AlreadyHit then
  3178. CommonVariables.AlreadyHit = true
  3179. ShatterGlass:FireServer(Hit, RegionalHitbox and Hit.Position or RaycastHitboxTable[2], (Hit.Position - HumanoidRootPart.Position).Unit)
  3180. if not CurrentModule.TriggerEffectOnce then
  3181. Thread:Delay(CurrentModule.EffectDelay, function()
  3182. CommonVariables.AlreadyHit = false
  3183. end)
  3184. end
  3185. end
  3186. else
  3187. local Target = Hit:FindFirstAncestorOfClass("Model")
  3188. local CanBlock
  3189. local TargetHumanoid
  3190. local TargetTorso
  3191. local TargetTorso2
  3192. if Target then
  3193. CanBlock = Target:FindFirstChild("CanBlock")
  3194. TargetHumanoid = Target:FindFirstChildOfClass("Humanoid")
  3195. TargetTorso = Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Head")
  3196. TargetTorso2 = Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Torso") or Target:FindFirstChild("UpperTorso")
  3197. end
  3198. local Misc = {
  3199. Tool = Tool,
  3200. ModuleName = CurrentModule.ModuleName,
  3201. Direction = ((TargetTorso and TargetTorso.Position or Hit.Position) - HumanoidRootPart.Position).Unit,
  3202. Blocked = false,
  3203. }
  3204. local ShouldBlock = false
  3205. local TEAM = Character:FindFirstChild("TEAM")
  3206. if CanBlock and CurrentModule.BlockMelee then
  3207. if TEAM and CanBlock:FindFirstChild("TEAM") then
  3208. if CanBlock.TEAM.Value ~= TEAM.Value then
  3209. ShouldBlock = true
  3210. Misc.Blocked = ShouldBlock
  3211. end
  3212. else
  3213. ShouldBlock = true
  3214. Misc.Blocked = ShouldBlock
  3215. end
  3216. end
  3217. local Pos = RegionalHitbox and Hit.Position or RaycastHitboxTable[2]
  3218. local Normal = RegionalHitbox and Vector3.new(0, 0, 0) or RaycastHitboxTable[3]
  3219. local Material = RegionalHitbox and Hit.Material or RaycastHitboxTable[4]
  3220. if TargetHumanoid and TargetTorso then
  3221. Pos = RegionalHitbox and TargetTorso2.Position or RaycastHitboxTable[2]
  3222. if ShouldBlock then
  3223. if not table.find(CommonVariables.BlockedModels, Target) then
  3224. table.insert(CommonVariables.BlockedModels, Target)
  3225. if not RegionalHitbox and CurrentModule.BlockDelay ~= math.huge then
  3226. Thread:Delay(CurrentModule.BlockDelay, function()
  3227. local Index = table.find(CommonVariables.BlockedModels, Target)
  3228. if Index then
  3229. table.remove(CommonVariables.BlockedModels, Index)
  3230. end
  3231. end)
  3232. end
  3233. gunEvent:Fire("VisualizeHitEffect", "Normal", Hit, Pos, Normal, Material, Misc, true)
  3234. end
  3235. return
  3236. end
  3237. if TargetHumanoid.Health > 0 then
  3238. if DamageModule.CanDamage(Target, Character, CurrentModule.FriendlyFire) then
  3239. if #CommonVariables.MeleeHitHumanoids < CurrentModule.MaxHits then
  3240. if not table.find(CommonVariables.MeleeHitHumanoids, TargetHumanoid) and not table.find(CommonVariables.BlockedModels, Target) then
  3241. table.insert(CommonVariables.MeleeHitHumanoids, TargetHumanoid)
  3242. if not RegionalHitbox and CurrentModule.HitIgnoreDelay ~= math.huge then
  3243. Thread:Delay(CurrentModule.HitIgnoreDelay, function()
  3244. local Index = table.find(CommonVariables.MeleeHitHumanoids, TargetHumanoid)
  3245. if Index then
  3246. table.remove(CommonVariables.MeleeHitHumanoids, Index)
  3247. end
  3248. end)
  3249. end
  3250. gunEvent:Fire("VisualizeHitEffect", "Blood", Hit, Pos, Normal, Material, Misc, true)
  3251. Thread:Spawn(function()
  3252. InflictTarget:FireServer("GunMelee", Tool, Hit, Hit.Size, CurrentModule.ModuleName)
  3253. end)
  3254. MarkHit(CurrentModule, Hit.Name == "Head" and CurrentModule.MeleeHeadshotHitmarker)
  3255. end
  3256. end
  3257. end
  3258. end
  3259. else
  3260. if ShouldBlock then
  3261. if not table.find(CommonVariables.BlockedModels, Target) then
  3262. table.insert(CommonVariables.BlockedModels, Target)
  3263. if not RegionalHitbox and CurrentModule.BlockDelay ~= math.huge then
  3264. Thread:Delay(CurrentModule.BlockDelay, function()
  3265. local Index = table.find(CommonVariables.BlockedModels, Target)
  3266. if Index then
  3267. table.remove(CommonVariables.BlockedModels, Index)
  3268. end
  3269. end)
  3270. end
  3271. gunEvent:Fire("VisualizeHitEffect", "Normal", Hit, Pos, Normal, Material, Misc, true)
  3272. end
  3273. else
  3274. if not CommonVariables.AlreadyHit then
  3275. CommonVariables.AlreadyHit = true
  3276. gunEvent:Fire("VisualizeHitEffect", "Normal", Hit, Pos, Normal, Material, Misc, true)
  3277. if not CurrentModule.TriggerEffectOnce then
  3278. Thread:Delay(CurrentModule.EffectDelay, function()
  3279. CommonVariables.AlreadyHit = false
  3280. end)
  3281. end
  3282. end
  3283. end
  3284. end
  3285. end
  3286. end
  3287.  
  3288. function OnMeleeAttacking()
  3289. if CurrentModule.MeleeAttackEnabled then
  3290. if CurrentAnimTable.MeleeAttackAnim and CurrentAnimTable.MeleeAttackAnim.Length > 0 then
  3291. local Connection
  3292. local Connection2
  3293. if CommonVariables.ActuallyEquipped and CommonVariables.Enabled and not CommonVariables.Overheated and not CommonVariables.Switching and not CommonVariables.Alting and not CommonVariables.AimDown and Humanoid.Health > 0 and CanShoot() then
  3294. if Module.CancelReload then
  3295. if CommonVariables.Reloading and not CommonVariables.CanCancelReload then
  3296. CommonVariables.CanCancelReload = true
  3297. end
  3298. else
  3299. if CommonVariables.Reloading then
  3300. return
  3301. end
  3302. end
  3303. CommonVariables.Enabled = false
  3304. SetAnimationTrack("InspectAnim", "Stop", nil, 0)
  3305. SetAnimationTrack("MeleeAttackAnim", "Play", CurrentModule.MeleeAttackAnimationSpeed, 0.05)
  3306. if CommonVariables.ActuallyEquipped and HandleToFire[CurrentFireMode]:FindFirstChild("MeleeSwingSound") then
  3307. HandleToFire[CurrentFireMode].MeleeSwingSound:Play()
  3308. end
  3309. Connection = CurrentAnimTable.MeleeAttackAnim:GetMarkerReachedSignal("MeleeDamageSequence"):Connect(function(ParamString)
  3310. --print(ParamString)
  3311. table.clear(CommonVariables.BlockedModels)
  3312. table.clear(CommonVariables.MeleeHitHumanoids)
  3313.  
  3314. if CurrentModule.HitboxType == "RotatedRegion" then
  3315. local RegionalHitbox = Instance.new("Part")
  3316. RegionalHitbox.CanCollide = false
  3317. RegionalHitbox.CastShadow = false
  3318. RegionalHitbox.Massless = true
  3319. RegionalHitbox.Transparency = 1
  3320. RegionalHitbox.Material = Enum.Material.SmoothPlastic
  3321. RegionalHitbox.Shape = CurrentModule.HitboxShape
  3322. RegionalHitbox.Size = CurrentModule.HitboxSize
  3323. RegionalHitbox.Color = Color3.new(1, 0, 0)
  3324. RegionalHitbox.CFrame = HumanoidRootPart.CFrame * CurrentModule.HitboxCFrame
  3325. RegionalHitbox.Parent = Camera
  3326. local Weld = Instance.new("WeldConstraint")
  3327. Weld.Part0 = RegionalHitbox
  3328. Weld.Part1 = HumanoidRootPart
  3329. Weld.Parent = RegionalHitbox
  3330. local Region = RotatedRegion3.new(RegionalHitbox.CFrame, RegionalHitbox.Size)
  3331. local RegionTable = Region:FindPartsInRegion3WithIgnoreList(IgnoreList, CurrentModule.MaxPartsInRegion)
  3332. for _, v in pairs(RegionTable) do
  3333. if v and v.Parent ~= nil then
  3334. OnMeleeHit(v, RegionalHitbox, nil)
  3335. end
  3336. end
  3337. Debris:AddItem(RegionalHitbox, 0.2)
  3338. else
  3339. if CurrentModule.TriggerEffectOnce then
  3340. CommonVariables.AlreadyHit = false
  3341. end
  3342.  
  3343. local HBI = GetInstanceFromAncestor(CurrentModule.RaycastHitboxInstances[1])
  3344. local HBI2
  3345.  
  3346. if CurrentModule.RaycastHitboxInstances[2] then
  3347. HBI2 = GetInstanceFromAncestor(CurrentModule.RaycastHitboxInstances[2])
  3348. end
  3349.  
  3350. if HBI and HBI:FindFirstChild("DamagePoint", true) then
  3351. if not CommonVariables.Hitbox then
  3352. CommonVariables.Hitbox = RaycastHitbox.new(HBI)
  3353. CommonVariables.Hitbox.RaycastParams = RayParams
  3354. CommonVariables.Hitbox.DetectionMode = RaycastHitbox.DetectionMode.PartMode
  3355. CommonVariables.Hitbox.OnHit:Connect(function(part, humanoid, raycastResult)
  3356. if part and part.Parent ~= nil then
  3357. OnMeleeHit(part, nil, {raycastResult.Instance, raycastResult.Position, raycastResult.Normal, raycastResult.Material})
  3358. end
  3359. end)
  3360. CommonVariables.Hitbox:HitStart()
  3361. end
  3362. end
  3363.  
  3364. if HBI2 and HBI2:FindFirstChild("DamagePoint", true) then
  3365. if not CommonVariables.Hitbox2 then
  3366. CommonVariables.Hitbox2 = RaycastHitbox.new(HBI2)
  3367. CommonVariables.Hitbox2.RaycastParams = RayParams
  3368. CommonVariables.Hitbox2.DetectionMode = RaycastHitbox.DetectionMode.PartMode
  3369. CommonVariables.Hitbox2.OnHit:Connect(function(part, humanoid, raycastResult)
  3370. if part and part.Parent ~= nil then
  3371. OnMeleeHit(part, nil, {raycastResult.Instance, raycastResult.Position, raycastResult.Normal, raycastResult.Material})
  3372. end
  3373. end)
  3374. CommonVariables.Hitbox2:HitStart()
  3375. end
  3376. end
  3377. end
  3378.  
  3379. if Connection then
  3380. --print("Disconnected")
  3381. Connection:Disconnect()
  3382. Connection = nil
  3383. end
  3384. end)
  3385. Connection2 = CurrentAnimTable.MeleeAttackAnim:GetMarkerReachedSignal("MeleeDamageEndSequence"):Connect(function(ParamString)
  3386. --print(ParamString)
  3387. if CommonVariables.Hitbox then
  3388. CommonVariables.Hitbox:HitStop()
  3389. CommonVariables.Hitbox:Destroy()
  3390. CommonVariables.Hitbox = nil
  3391. end
  3392. if CommonVariables.Hitbox2 then
  3393. CommonVariables.Hitbox2:HitStop()
  3394. CommonVariables.Hitbox2:Destroy()
  3395. CommonVariables.Hitbox2 = nil
  3396. end
  3397.  
  3398. if Connection2 then
  3399. --print("Disconnected")
  3400. Connection2:Disconnect()
  3401. Connection2 = nil
  3402. end
  3403. end)
  3404. CurrentAnimTable.MeleeAttackAnim.Stopped:Wait()
  3405. if CommonVariables.Hitbox then
  3406. CommonVariables.Hitbox:HitStop()
  3407. CommonVariables.Hitbox:Destroy()
  3408. CommonVariables.Hitbox = nil
  3409. end
  3410. if CommonVariables.Hitbox2 then
  3411. CommonVariables.Hitbox2:HitStop()
  3412. CommonVariables.Hitbox2:Destroy()
  3413. CommonVariables.Hitbox2 = nil
  3414. end
  3415. CommonVariables.Enabled = true
  3416. end
  3417. end
  3418. end
  3419. end
  3420.  
  3421. function OnUnequipping(Remove)
  3422. if Module.CustomGripEnabled and not Tool.RequiresHandle then
  3423. SetCustomGrip(false)
  3424. end
  3425. if Module.DualWeldEnabled and not Module.CustomGripEnabled and Tool.RequiresHandle then
  3426. if CommonVariables.Grip2 then
  3427. CommonVariables.Grip2:Destroy()
  3428. end
  3429. end
  3430.  
  3431. if CurrentModule.ChargedShotAdvanceEnabled then
  3432. CommonVariables.Charging = false
  3433. end
  3434. if CurrentModule.HoldAndReleaseEnabled then
  3435. CommonVariables.Charged = false
  3436. end
  3437. CommonVariables.Equipped = false
  3438. CommonVariables.ActuallyEquipped = false
  3439. if JumpButton then
  3440. MobileButtons.AimButton.Parent = GUI.MobileButtons
  3441. MobileButtons.FireButton.Parent = GUI.MobileButtons
  3442. MobileButtons.HoldDownButton.Parent = GUI.MobileButtons
  3443. MobileButtons.InspectButton.Parent = GUI.MobileButtons
  3444. MobileButtons.ReloadButton.Parent = GUI.MobileButtons
  3445. MobileButtons.SwitchButton.Parent = GUI.MobileButtons
  3446. MobileButtons.AltButton.Parent = GUI.MobileButtons
  3447. end
  3448. GUI.Parent = script
  3449. UserInputService.MouseIconEnabled = true
  3450. RunService:UnbindFromRenderStep(BindToStepName)
  3451. RemoveStuff(true)
  3452. if CurrentModule.BatteryEnabled then
  3453. gunEvent:Fire("VisualizeOverheat", CurrentModule.OverheatEffect, "End", Character, Tool, HandleToFire, true)
  3454. end
  3455. if Remove then
  3456. if CurrentModule.LaserBeam then
  3457. VisibleMuzz(HandleToFire:FindFirstChild("GunMuzzlePoint"..CurrentFireMode), false)
  3458. VisibleMuzzle:FireServer(HandleToFire:FindFirstChild("GunMuzzlePoint"..CurrentFireMode), false)
  3459. gunEvent:Fire("RemoveBeam", GUID, Tool, CurrentModule.ModuleName, BeamTable, CommonVariables.LaserTrail, CommonVariables.BoltSegments, CrosshairPointAttachment)
  3460. end
  3461. end
  3462. SetADS(true)
  3463. end
  3464.  
  3465. MobileButtons.AimButton.MouseButton1Click:Connect(function()
  3466. SetADS()
  3467. end)
  3468.  
  3469. MobileButtons.HoldDownButton.MouseButton1Click:Connect(function()
  3470. OnHoldingDown()
  3471. end)
  3472.  
  3473. MobileButtons.InspectButton.MouseButton1Click:Connect(function()
  3474. OnInspecting()
  3475. end)
  3476.  
  3477. MobileButtons.SwitchButton.MouseButton1Click:Connect(function()
  3478. OnSwitching()
  3479. end)
  3480.  
  3481. MobileButtons.ReloadButton.MouseButton1Click:Connect(function()
  3482. Reload()
  3483. end)
  3484.  
  3485. MobileButtons.FireButton.MouseButton1Down:Connect(function()
  3486. OnFiring()
  3487. end)
  3488.  
  3489. MobileButtons.FireButton.MouseButton1Up:Connect(function()
  3490. OnStoppingFiring()
  3491. end)
  3492.  
  3493. MobileButtons.SubFireButton.MouseButton1Down:Connect(function()
  3494. OnFiring()
  3495. end)
  3496.  
  3497. MobileButtons.SubFireButton.MouseButton1Up:Connect(function()
  3498. OnStoppingFiring()
  3499. end)
  3500.  
  3501. MobileButtons.MeleeButton.MouseButton1Click:Connect(function()
  3502. OnMeleeAttacking()
  3503. end)
  3504.  
  3505. MobileButtons.AltButton.MouseButton1Click:Connect(function()
  3506. OnAlting()
  3507. end)
  3508.  
  3509. UserInputService.InputBegan:Connect(function(Input, GameProcessed)
  3510. if GameProcessed then
  3511. return
  3512. end
  3513. if not UserInputService.TouchEnabled then
  3514. local InputType
  3515. if Input.UserInputType == Enum.UserInputType.Keyboard then
  3516. InputType = "Keyboard"
  3517. elseif Input.UserInputType == Enum.UserInputType.Gamepad1 then
  3518. InputType = "Controller"
  3519. end
  3520. local CanADS = ((Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1)
  3521. if Module.ThirdPersonADS then
  3522. CanADS = ((Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1) or (UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter)
  3523. end
  3524. if Input.UserInputType == Enum.UserInputType.MouseButton1 or (InputType == "Controller" and Input.KeyCode == Module.Controller.Fire) then
  3525. OnFiring()
  3526. elseif Input.UserInputType == Enum.UserInputType.MouseButton2 and CanADS then
  3527. SetADS()
  3528. end
  3529. if InputType then
  3530. if Input.KeyCode == Module[InputType].Reload then
  3531. Reload()
  3532. elseif Input.KeyCode == Module[InputType].HoldDown then
  3533. OnHoldingDown()
  3534. elseif Input.KeyCode == Module[InputType].Inspect then
  3535. OnInspecting()
  3536. elseif Input.KeyCode == Module[InputType].Switch then
  3537. OnSwitching()
  3538. elseif Input.KeyCode == Module[InputType].ToogleAim then
  3539. SetADS()
  3540. elseif Input.KeyCode == Module[InputType].Melee then
  3541. OnMeleeAttacking()
  3542. elseif Input.KeyCode == Module[InputType].AltFire then
  3543. OnAlting()
  3544. end
  3545. end
  3546. end
  3547. end)
  3548.  
  3549. UserInputService.InputEnded:Connect(function(Input, GameProcessed)
  3550. if GameProcessed then
  3551. return
  3552. end
  3553. if not UserInputService.TouchEnabled then
  3554. local InputType
  3555. if Input.UserInputType == Enum.UserInputType.Keyboard then
  3556. InputType = "Keyboard"
  3557. elseif Input.UserInputType == Enum.UserInputType.Gamepad1 then
  3558. InputType = "Controller"
  3559. end
  3560. local CanADS = ((Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1)
  3561. if Module.ThirdPersonADS then
  3562. CanADS = ((Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1) or (UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter)
  3563. end
  3564. if Input.UserInputType == Enum.UserInputType.MouseButton1 or (InputType == "Controller" and Input.KeyCode == Module.Controller.Fire) then
  3565. OnStoppingFiring()
  3566. elseif Input.UserInputType == Enum.UserInputType.MouseButton2 and CanADS then
  3567. SetADS(true)
  3568. end
  3569. end
  3570. end)
  3571.  
  3572. MarkerEvent.Event:Connect(MarkHit)
  3573.  
  3574. ChangeMagAndAmmo.OnClientEvent:Connect(function(Values, Ammo)
  3575. for i, v in ipairs(Values) do
  3576. Variables[v.Id].Mag = v.Mag
  3577. if not Module.UniversalAmmoEnabled then
  3578. Variables[v.Id].Ammo = v.Ammo
  3579. end
  3580. Variables[v.Id].Heat = v.Heat
  3581. end
  3582. if Module.UniversalAmmoEnabled then
  3583. UniversalTable.Ammo = Ammo
  3584. end
  3585. UpdateGUI()
  3586. end)
  3587.  
  3588. Tool.Equipped:Connect(function()
  3589. if Module.CustomGripEnabled and not Tool.RequiresHandle then
  3590. task.spawn(function()
  3591. SetCustomGrip(true)
  3592. end)
  3593. end
  3594. if Module.DualWeldEnabled and not Module.CustomGripEnabled and Tool.RequiresHandle then
  3595. task.spawn(function()
  3596. if RightArm then
  3597. local Grip = RightArm:WaitForChild("RightGrip", 0.01)
  3598. if Grip then
  3599. CommonVariables.Grip2 = Grip:Clone()
  3600. CommonVariables.Grip2.Name = "LeftGrip"
  3601. CommonVariables.Grip2.Part0 = LeftArm
  3602. CommonVariables.Grip2.Part1 = CommonVariables.Handle2
  3603. --CommonVariables.Grip2.C1 = Grip2.C1:inverse()
  3604. CommonVariables.Grip2.Parent = LeftArm
  3605. end
  3606. end
  3607. end)
  3608. end
  3609.  
  3610. CommonVariables.Equipped = true
  3611. if JumpButton then
  3612. MobileButtons.AimButton.Parent = JumpButton
  3613. MobileButtons.FireButton.Parent = JumpButton
  3614. MobileButtons.HoldDownButton.Parent = JumpButton
  3615. MobileButtons.InspectButton.Parent = JumpButton
  3616. MobileButtons.ReloadButton.Parent = JumpButton
  3617. MobileButtons.SwitchButton.Parent = JumpButton
  3618. MobileButtons.AltButton.Parent = JumpButton
  3619. end
  3620. GUI.Parent = Player.PlayerGui
  3621. UpdateGUI()
  3622. UserInputService.MouseIconEnabled = false
  3623.  
  3624. SetCrossSettings(CurrentModule.CrossSize, CurrentModule.CrossSpeed, CurrentModule.CrossDamper)
  3625.  
  3626. if CommonVariables.Radar == nil then
  3627. CommonVariables.Radar = Scanners.Radars[CurrentModule.Radar]:Clone()
  3628. CommonVariables.Radar.Name = "Scanner"
  3629. CommonVariables.Radar.Parent = GUI
  3630. end
  3631.  
  3632. if CurrentModule.ProjectileMotion then
  3633. local MotionBeam = GunVisualEffects:FindFirstChild(CurrentModule.MotionBeam)
  3634. if MotionBeam then
  3635. CommonVariables.Beam, CommonVariables.Attach0, CommonVariables.Attach1 = ProjectileMotion.ShowProjectilePath(MotionBeam, HandleToFire:FindFirstChild("GunFirePoint"..CurrentFireMode).WorldPosition, Vector3.new(), 3, AddressTableValue("Acceleration", CurrentModule))
  3636. end
  3637. end
  3638.  
  3639. RunService:BindToRenderStep(BindToStepName, Enum.RenderPriority.Camera.Value, Render)
  3640.  
  3641. for _, v in pairs(CommonVariables.Keyframes) do
  3642. table.insert(CommonVariables.KeyframeConnections, v[1]:GetMarkerReachedSignal("AnimationEvents"):Connect(function(keyframeName)
  3643. if v[2][keyframeName] then
  3644. v[2][keyframeName](keyframeName, Tool)
  3645. end
  3646. end))
  3647. end
  3648.  
  3649. if CurrentAnimTable.EmptyEquippedAnim and CurrentVariables.Mag <= 0 then
  3650. SetAnimationTrack("EmptyEquippedAnim", "Play", CurrentModule.EmptyEquippedAnimationSpeed)
  3651. HandleToFire[CurrentFireMode].EmptyEquippedSound:Play()
  3652. else
  3653. SetAnimationTrack("EquippedAnim", "Play", CurrentModule.EquippedAnimationSpeed)
  3654. HandleToFire[CurrentFireMode].EquippedSound:Play()
  3655. end
  3656.  
  3657. if CurrentAnimTable.EmptyIdleAnim and CurrentVariables.Mag <= 0 then
  3658. SetAnimationTrack("EmptyIdleAnim", "Play", CurrentModule.EmptyIdleAnimationSpeed)
  3659. else
  3660. SetAnimationTrack("IdleAnim", "Play", CurrentModule.IdleAnimationSpeed)
  3661. end
  3662.  
  3663. local StartTime = os.clock() repeat Thread:Wait() if not CommonVariables.Equipped then break end until (os.clock() - StartTime) >= ((CurrentVariables.Mag <= 0) and CurrentModule.EmptyEquipTime or CurrentModule.EquipTime)
  3664. if CommonVariables.Equipped then
  3665. CommonVariables.ActuallyEquipped = true
  3666. end
  3667.  
  3668. if CommonVariables.ActuallyEquipped and Module.AutoReload and CurrentVariables.Mag <= 0 then
  3669. Reload()
  3670. end
  3671. end)
  3672.  
  3673. Tool.Unequipped:Connect(function()
  3674. OnUnequipping(Tool.Parent == Workspace)
  3675. end)
  3676.  
  3677. Humanoid.Died:Connect(function()
  3678. OnUnequipping(true)
  3679. end)
  3680.  
  3681. Tool.AncestryChanged:Connect(function()
  3682. if not Tool:IsDescendantOf(game) then
  3683. OnUnequipping(true)
  3684. end
  3685. end)
Add Comment
Please, Sign In to add comment