System: You will be given a Luau script (that has been decompiled). You will rename the variables and functions to sound better, make the script more coherent, and add comments to areas of the script. Return the fixed script without adding ``` as we handle that. If no script has been given, do not produce any output. Do not respond with anything but the script
User: -- Decompiler will be improved soon!
-- Decompiled with Konstant V2.1, a fast Luau decompiler made in Luau by plusgiant5 (https://discord.gg/wyButjTMhM)
-- Decompiled on 2025-02-11 11:51:35
-- Luau version 6, Types version 3
-- Time taken: 0.021991 seconds

local Assets_upvr = game:GetService("ReplicatedStorage").Assets
local Modules = game:GetService("ReplicatedStorage").Modules
local Shared_upvr = require(Modules.Core.Shared)
local Matchmaking_upvr = require(Modules.Core.Matchmaking)
local module_upvr = {
	["Rocket Fired"] = false;
	["Rocket Time"] = 0.5;
	Rockets = 1;
	["Burst Interval"] = 0;
	["Minigun Active"] = false;
	P1 = {
		ID = 1177475221;
		Volume = 0.75;
		Pitch = 1;
	};
	P2 = {
		ID = 165772772;
		Volume = 0.75;
		Pitch = 1;
	};
	Explode = {
		ID = 170278900;
		Volume = 0.5;
		Pitch = 1;
	};
	Phases = {
		Enabled = true;
		Level = 0;
		Segments = {{
			Min = 0.65;
			Max = 0.8;
		}, {
			Min = 0;
			Max = 0.65;
		}};
	};
	["Special Attacks"] = {
		Enabled = true;
		Rate = 5;
		Multiplier = 1;
		Used = false;
		Moveset = {{
			Name = "Rocket Flurry";
			Amount = 175;
			Rate = 0.04;
			Cooldown = 10;
			Damage = 125;
			StatueMult = 1.5;
			Velocity = 500;
			Range = 45;
			Particle = Assets_upvr.Gameplay.Particles:WaitForChild("RocketEXP");
			Explode = {
				ID = 4612378521;
				Volume = 0.25;
				Pitch = 1;
			};
			Launch = {
				ID = 5801273676;
				Volume = 0.375;
				Pitch = 1.5;
			};
			Pods = {CFrame.new(-0.5, 2.874, -4.637), CFrame.new(1, 2.874, -4.637), CFrame.new(1, 1.337, -4.637), CFrame.new(-0.5, 1.337, -4.637)};
		}, {
			Name = "Minigun Barrage";
			PrepTime = 1;
			Duration = 60;
			Cooldown = 6;
			StartUp = {
				ID = 2692844;
				Volume = 0.75;
				Pitch = 1;
			};
			End = {
				ID = 2692801;
				Volume = 0.75;
				Pitch = 1;
			};
		}};
	};
}
local var22_upvr = Matchmaking_upvr["Difficulty Nomenclature"][Assets_upvr.Session.Difficulty.Value]
local function UseSpecial_upvr(arg1, arg2, arg3, arg4, arg5, arg6) -- Line 95, Named "UseSpecial"
	--[[ Upvalues[5]:
		[1]: Assets_upvr (readonly)
		[2]: Shared_upvr (readonly)
		[3]: module_upvr (readonly)
		[4]: var22_upvr (readonly)
		[5]: Matchmaking_upvr (readonly)
	]]
	-- KONSTANTWARNING: Variable analysis failed. Output will have some incorrect variable assignments
	if not arg1 or not arg5 or not arg5.Parent or not arg2 or 0 >= arg2.Health then
	else
		if arg1.MinDifficulty and Assets_upvr.Session.Difficulty.Value < arg1.MinDifficulty then return end
		if arg1.Cue and arg1.Cue.ID then
			Shared_upvr.CreateSound(arg1.Cue, arg3)
		end
		if arg1.Name == "Minigun Barrage" then
			if 2 <= module_upvr.Phases.Level then return end
			delay(arg1.PrepTime, function() -- Line 107
				--[[ Upvalues[1]:
					[1]: module_upvr (copied, readonly)
				]]
				module_upvr["Minigun Active"] = true
			end)
			Shared_upvr.CreateSound(arg1.StartUp, arg3)
			wait(arg1.Duration)
			module_upvr["Minigun Active"] = false
			Shared_upvr.CreateSound(arg1.End, arg3)
		end
		local var90
		if arg1.Name == "Rocket Flurry" then
			local Handle_2 = arg5:WaitForChild("Shoulder Rocket Launcher").Handle
			if 4 > Assets_upvr.Session.Difficulty.Value then
				var90 = false
			else
				var90 = true
			end
			local RaycastParams_new_result1_3 = RaycastParams.new()
			RaycastParams_new_result1_3.FilterDescendantsInstances = {}
			RaycastParams_new_result1_3.FilterType = Enum.RaycastFilterType.Exclude
			if not var90 or not (arg1.Amount * 2) then
			end
			for _ = 1, arg1.Amount do
				local tbl_4 = {}
				RaycastParams_new_result1_3.FilterDescendantsInstances = Shared_upvr.CreateIgnoreList(arg5, false, true)
				for i_4, v_3 in pairs(workspace:GetChildren()) do
					if v_3:FindFirstChild("Humanoid") and v_3.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and not v_3:FindFirstChildOfClass("ForceField") and v_3 ~= arg5 then
						local Humanoid_6 = v_3:FindFirstChild("Humanoid")
						if Humanoid_6 and Humanoid_6:GetState() ~= Enum.HumanoidStateType.Dead and v_3:FindFirstChild("TEAM") then
							-- KONSTANTERROR: Expression was reused, decompilation is incorrect
							local var98
							if v_3:FindFirstChild("TEAM").Value ~= var98 then
								var98 = nil
								local workspace_Raycast_result1_6 = workspace:Raycast(Handle_2.CFrame.Position, CFrame.new(Handle_2.CFrame.Position, v_3:FindFirstChild("HumanoidRootPart").CFrame.Position).LookVector * 1000, RaycastParams_new_result1_3)
								if workspace_Raycast_result1_6 then
									var98 = workspace_Raycast_result1_6.Instance
								end
								if var98 and var98.Parent and var98:IsDescendantOf(v_3) then
									table.insert(tbl_4, v_3)
								end
							end
						end
					end
				end
				if 0 < #tbl_4 then
					i_4 = 1
					v_3 = #tbl_4
					local var100 = tbl_4[Random.new():NextInteger(i_4, v_3)]
					if var100 then
						local var101
						if var100.Parent then
							local tbl_8 = {}
							var101 = nil
							i_4 = pairs
							v_3 = var100:GetChildren()
							i_4 = i_4(v_3)
							local i_4_result1, i_4_result2, i_4_result3 = i_4(v_3)
							for i_5, v_4 in i_4_result1, i_4_result2, i_4_result3 do
								if arg5 and arg5.PrimaryPart and v_4 and v_4:IsA("BasePart") then
									local var106 = arg5.PrimaryPart.CFrame * CFrame.new(0, 1.5, 0).Position
									local RaycastParams_new_result1_6 = RaycastParams.new()
									RaycastParams_new_result1_6.FilterDescendantsInstances = {v_4, workspace.Map}
									RaycastParams_new_result1_6.FilterType = Enum.RaycastFilterType.Include
									local workspace_Raycast_result1_5 = workspace:Raycast(var106, CFrame.new(var106, v_4.CFrame.Position).LookVector * 2048, RaycastParams_new_result1_6)
									if workspace_Raycast_result1_5 and workspace_Raycast_result1_5.Instance and workspace_Raycast_result1_5.Instance:IsDescendantOf(var100) then
										table.insert(tbl_8, v_4)
									end
								end
							end
							i_4_result1 = #tbl_8
							i_4_result2 = 0
							if i_4_result2 < i_4_result1 then
								i_4_result1 = Random.new()
								i_5 = #tbl_8
								i_4_result1 = i_4_result1:NextInteger(1, i_5)
								var101 = tbl_8[i_4_result1]
							end
							if var101 then
								i_4_result1 = var101.Parent
								if i_4_result1 then
									i_4_result1 = arg2.Health
									i_4_result2 = 0
									local var110
									if i_4_result2 < i_4_result1 then
										v_4 = Instance.new("Part")
										i_4_result1 = v_4
										v_4 = Instance.new("SpecialMesh")
										i_4_result2 = v_4
										v_4 = Instance.new("BodyForce")
										local var111 = v_4
										i_5 = 1.5
										v_4 = Vector3.new(1, 1, 4)
										var110 = Handle_2.CFrame
										var110 = var101.CFrame
										var110 = Random.new():NextInteger(-1.5, 1.5)
										var110 = math.rad(Random.new():NextInteger(-1.5, 1.5))
										i_4_result1.Size = v_4
										i_4_result1.CanCollide = false
										i_4_result1.Color = Color3.fromRGB(255, 125, 125)
										i_4_result1.CFrame = CFrame.new((var110 * arg1.Pods[Random.new():NextInteger(1, #arg1.Pods)]).Position, var110.Position) * CFrame.Angles(math.rad(var110), var110, math.rad(Random.new():NextInteger(-1.5, 1.5)))
										i_4_result1.Name = "TMA-Rocket"
										v_4 = i_4_result1.CFrame.LookVector * arg1.Velocity
										i_4_result1.Velocity = v_4
										v_4 = "rbxassetid://103970395"
										i_4_result2.MeshId = v_4
										i_4_result2.TextureId = "rbxassetid://103967643"
										i_4_result2.Scale = Vector3.new(4.40000, 4.40000, 4.40000)
										i_4_result2.Parent = i_4_result1
										v_4 = Vector3.new(0, i_4_result1:GetMass() * workspace.Gravity, 0)
										var111.Force = v_4
										var111.Parent = i_4_result1
										v_4 = Shared_upvr.CreateTrail
										v_4({
											Object = i_4_result1;
											CustomColor = nil;
											AlignmentType = 'X';
										})
										v_4 = i_4_result1.Touched
										local tbl_5 = {
											Object = i_4_result1;
										}
										tbl_5.NPC = arg5
										tbl_5.Team = arg4
										tbl_5.Humanoid = arg2
										tbl_5.Piercing = false
										local function INLINED_2() -- Internal function, doesn't exist in bytecode
											var110 = var22_upvr.DamageMultiplier
											return var110
										end
										if not var22_upvr or not INLINED_2() then
											var110 = 1
										end
										var110 = Matchmaking_upvr
										tbl_5.Damage = arg1.Damage * var110 * var110["Global Scaling"]
										tbl_5.StatueMult = arg1.StatueMult or 1
										tbl_5.Knockback = nil
										tbl_5.Lifesteal = nil
										var110 = module_upvr
										if 2 > var110.Phases.Level or not script:FindFirstChild("EnemyEffect") then
										end
										tbl_5.Special = nil
										tbl_5.Explosive = true
										tbl_5.Range = arg1.Range
										tbl_5.SFX = arg1.Explode
										tbl_5.Particle = arg1.Particle
										tbl_5.Element = nil
										v_4 = v_4:Connect
										v_4(Shared_upvr.TouchFunction(tbl_5))
										v_4 = workspace.JunkHolder
										i_4_result1.Parent = v_4
										v_4 = i_4_result1:SetNetworkOwner
										v_4(nil)
										v_4 = Shared_upvr.CreateSound
										v_4(arg1.Launch, i_4_result1)
										v_4 = Shared_upvr.Overshoot
										v_4(i_4_result1)
										v_4 = game:GetService("Debris"):AddItem
										v_4(i_4_result1, 5)
									end
								end
							end
							i_4_result1 = wait
							i_4_result2 = arg1.Rate
							i_4_result1(i_4_result2)
						end
					end
				end
			end
		end
	end
end
local RunService_upvr = game:GetService("RunService")
local VFX_upvr = require(Modules.Gameplay.VFX)
local Storyline_upvr = require(Modules.Gameplay.Storyline)
local Resources_upvr = script.Parent:WaitForChild("Resources")
function module_upvr.Attack(arg1) -- Line 282
	--[[ Upvalues[8]:
		[1]: Shared_upvr (readonly)
		[2]: module_upvr (readonly)
		[3]: UseSpecial_upvr (readonly)
		[4]: RunService_upvr (readonly)
		[5]: VFX_upvr (readonly)
		[6]: Storyline_upvr (readonly)
		[7]: Resources_upvr (readonly)
		[8]: Assets_upvr (readonly)
	]]
	local Humanoid_5_upvr = arg1:WaitForChild("Humanoid", 2)
	local TEAM_upvr = arg1:WaitForChild("TEAM", 2)
	local PrimaryPart_upvr = arg1.PrimaryPart
	local var122_upvw
	local Stats_upvr = arg1:FindFirstChild("Stats")
	if Stats_upvr then
		Stats_upvr = require(arg1.Stats)
	end
	local function VerifyThisTarget_upvr(arg1_2) -- Line 300, Named "VerifyThisTarget"
		--[[ Upvalues[1]:
			[1]: Stats_upvr (readonly)
		]]
		-- KONSTANTWARNING: Variable analysis failed. Output will have some incorrect variable assignments
		local var124
		if var124 then
			var124 = arg1_2:FindFirstChild("Humanoid")
		end
		if not arg1_2 or Stats_upvr.Ranged ~= true or not arg1_2:FindFirstChild("Head") then
			if arg1_2 then
			end
		end
		if arg1_2 then
			local var125
		end
		if var124 and arg1_2.PrimaryPart and arg1_2:FindFirstChild("TEAM") then
			var125 = false
		end
		-- KONSTANTERROR: Expression was reused, decompilation is incorrect (x2)
		return var125, var124, arg1_2.PrimaryPart, arg1_2:FindFirstChild("TEAM")
	end
	local RaycastParams_new_result1_4_upvr = RaycastParams.new()
	local function FindClosestTarget_upvr(arg1_3) -- Line 310, Named "FindClosestTarget"
		--[[ Upvalues[7]:
			[1]: PrimaryPart_upvr (readonly)
			[2]: Shared_upvr (copied, readonly)
			[3]: arg1 (readonly)
			[4]: Stats_upvr (readonly)
			[5]: TEAM_upvr (readonly)
			[6]: RaycastParams_new_result1_4_upvr (readonly)
			[7]: VerifyThisTarget_upvr (readonly)
		]]
		local var164 = PrimaryPart_upvr.CFrame * CFrame.new(0, 1.5, 0).Position
		local _, pairs_result2_4, pairs_result3_3 = pairs(workspace:GetChildren())
		local var168
		for _, v in var168, pairs_result2_4, pairs_result3_3 do
			if v:FindFirstChild("Humanoid") and v.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and not v:FindFirstChildOfClass("ForceField") then
				if v ~= arg1 then
					local Humanoid_4 = v:FindFirstChild("Humanoid")
					local var170
					local function INLINED_5() -- Internal function, doesn't exist in bytecode
						var170 = v:FindFirstChild("Head")
						return var170
					end
					if Stats_upvr.Ranged ~= true or not INLINED_5() then
						var170 = v.PrimaryPart
					end
					if Humanoid_4 and Humanoid_4:GetState() ~= Enum.HumanoidStateType.Dead and var170 and v:FindFirstChild("TEAM") then
						-- KONSTANTERROR: Expression was reused, decompilation is incorrect
						local var171
						if v:FindFirstChild("TEAM").Value ~= var171 then
							var171 = nil
							RaycastParams_new_result1_4_upvr.FilterDescendantsInstances = Shared_upvr.CreateIgnoreList(arg1, false, true)
							RaycastParams_new_result1_4_upvr.FilterType = Enum.RaycastFilterType.Exclude
							RaycastParams_new_result1_4_upvr.IgnoreWater = true
							local workspace_Raycast_result1_3 = workspace:Raycast(var164, CFrame.new(var164, var170.CFrame.Position).LookVector * 2048, RaycastParams_new_result1_4_upvr)
							if workspace_Raycast_result1_3 then
								var171 = workspace_Raycast_result1_3.Instance
							end
							if var171 and var171.Parent and var171:IsDescendantOf(v) then
								table.insert({}, v)
							end
						end
					end
				end
			end
		end
		var168 = nil
		-- KONSTANTERROR: Expression was reused, decompilation is incorrect
		for _, v_2 in pairs({}) do
			local Humanoid_3 = v_2:FindFirstChild("Humanoid")
			local var177
			local function INLINED_6() -- Internal function, doesn't exist in bytecode
				var177 = v_2:FindFirstChild("Head")
				return var177
			end
			if Stats_upvr.Ranged ~= true or not INLINED_6() then
				var177 = v_2.PrimaryPart
			end
			local var178 = var177
			var177 = v_2:FindFirstChild("TEAM")
			if Humanoid_3 then
				var177 = Humanoid_3:GetState()
				if var177 ~= Enum.HumanoidStateType.Dead then
					var177 = Humanoid_3.Health
					if 0 < var177 and var178 and var177 then
						-- KONSTANTERROR: Expression was reused, decompilation is incorrect
						var177 = var177.Value
						if var177 ~= TEAM_upvr.Value then
							var177 = (var178.Position - arg1_3).Magnitude
							if var177 < math.huge then
								var168 = v_2
								var177 = var178.Position - arg1_3
							end
						end
					end
				end
			end
		end
		local _, VerifyThisTarget_result2_2, VerifyThisTarget_result3, _ = VerifyThisTarget_upvr(var168)
		-- KONSTANTERROR: Expression was reused, decompilation is incorrect
		return var168, VerifyThisTarget_result2_2, VerifyThisTarget_result3, v:FindFirstChild("TEAM")
	end
	if module_upvr["Special Attacks"].Enabled == true then
		coroutine.wrap(function() -- Line 380
			--[[ Upvalues[8]:
				[1]: module_upvr (copied, readonly)
				[2]: UseSpecial_upvr (copied, readonly)
				[3]: Humanoid_5_upvr (readonly)
				[4]: PrimaryPart_upvr (readonly)
				[5]: TEAM_upvr (readonly)
				[6]: arg1 (readonly)
				[7]: var122_upvw (read and write)
				[8]: RunService_upvr (copied, readonly)
			]]
			repeat
				wait(module_upvr["Special Attacks"].Rate * module_upvr["Special Attacks"].Multiplier)
				if module_upvr["Special Attacks"].Used == true then
					module_upvr["Special Attacks"].Used = false
				end
				if module_upvr["Special Attacks"].Used == false and 0 < #module_upvr["Special Attacks"].Moveset then
					local var184 = module_upvr["Special Attacks"].Moveset[Random.new():NextInteger(1, #module_upvr["Special Attacks"].Moveset)]
					UseSpecial_upvr(var184, Humanoid_5_upvr, PrimaryPart_upvr, TEAM_upvr, arg1, var122_upvw)
					wait(var184.Cooldown * module_upvr["Special Attacks"].Multiplier)
				end
				RunService_upvr.Heartbeat:Wait()
			until not arg1.Parent and (not Humanoid_5_upvr or Humanoid_5_upvr:GetState() == Enum.HumanoidStateType.Dead)
		end)()
	end
	local WalkSpeed_upvw = Humanoid_5_upvr.WalkSpeed
	local Aim_upvr = PrimaryPart_upvr.Aim
	local var188_upvw = false
	local RaycastParams_new_result1_5_upvr = RaycastParams.new()
	coroutine.wrap(function() -- Line 402
		--[[ Upvalues[16]:
			[1]: arg1 (readonly)
			[2]: Humanoid_5_upvr (readonly)
			[3]: FindClosestTarget_upvr (readonly)
			[4]: PrimaryPart_upvr (readonly)
			[5]: module_upvr (copied, readonly)
			[6]: VFX_upvr (copied, readonly)
			[7]: Shared_upvr (copied, readonly)
			[8]: Storyline_upvr (copied, readonly)
			[9]: WalkSpeed_upvw (read and write)
			[10]: var122_upvw (read and write)
			[11]: Stats_upvr (readonly)
			[12]: Aim_upvr (readonly)
			[13]: var188_upvw (read and write)
			[14]: RaycastParams_new_result1_5_upvr (readonly)
			[15]: Resources_upvr (copied, readonly)
			[16]: Assets_upvr (copied, readonly)
		]]
		-- KONSTANTERROR: [553] 394. Error Block 88 start (CF ANALYSIS FAILED)
		game:GetService("RunService").Heartbeat:Wait()
		-- KONSTANTERROR: [553] 394. Error Block 88 end (CF ANALYSIS FAILED)
		-- KONSTANTERROR: [0] 1. Error Block 127 start (CF ANALYSIS FAILED)
		-- KONSTANTWARNING: Failed to evaluate expression, replaced with nil [564.0]
		-- KONSTANTERROR: [0] 1. Error Block 127 end (CF ANALYSIS FAILED)
	end)()
end
return module_upvr
Assistant: