Assistant: 
User: 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: -- Decompiled with Konstant V2.1, a fast Luau decompiler made in Luau by plusgiant5 (https://discord.gg/wyButjTMhM)
-- Decompiled on 2024-10-06 16:14:45
-- Luau version 6, Types version 3
-- Time taken: 0.007559 seconds

if not game:IsLoaded() then
	game.Loaded:Wait()
end
local Lighting_upvr = game:GetService("Lighting")
local TweenService_upvr = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local var4_upvw = false
local LocalPlayer = game:GetService("Players").LocalPlayer
local Character_upvw = LocalPlayer.Character
if not Character_upvw then
	Character_upvw = LocalPlayer.CharacterAdded:Wait()
end
local HumanoidRootPart_upvw = Character_upvw:WaitForChild("HumanoidRootPart")
LocalPlayer.CharacterAdded:Connect(function(arg1) -- Line 25
	--[[ Upvalues[2]:
		[1]: HumanoidRootPart_upvw (read and write)
		[2]: Character_upvw (read and write)
	]]
	HumanoidRootPart_upvw = arg1:WaitForChild("HumanoidRootPart")
	Character_upvw = arg1
end)
local SettingsModule_upvr = require(ReplicatedStorage.SharedModules.SettingsModule)
SettingsModule_upvr:GetSavedSettings()
local UserGameSettings_upvr = UserSettings():GetService("UserGameSettings")
local Value_upvw = UserGameSettings_upvr.SavedQualityLevel.Value
UserGameSettings_upvr.Changed:Connect(function() -- Line 44
	--[[ Upvalues[2]:
		[1]: Value_upvw (read and write)
		[2]: UserGameSettings_upvr (readonly)
	]]
	Value_upvw = UserGameSettings_upvr.SavedQualityLevel.Value
end)
local function TweenTime_upvr(arg1, arg2) -- Line 49, Named "TweenTime"
	--[[ Upvalues[2]:
		[1]: Lighting_upvr (readonly)
		[2]: TweenService_upvr (readonly)
	]]
	Lighting_upvr.ClockTime = arg1
	local tbl_2 = {}
	tbl_2.ClockTime = arg2
	TweenService_upvr:Create(Lighting_upvr, TweenInfo.new(1, Enum.EasingStyle.Linear), tbl_2):Play()
end
local Weather_upvr = ReplicatedStorage.Render.Weather
local CurrentCamera_upvr = workspace.CurrentCamera
local function StartRain(arg1) -- Line 98
	--[[ Upvalues[6]:
		[1]: Weather_upvr (readonly)
		[2]: var4_upvw (read and write)
		[3]: Value_upvw (read and write)
		[4]: CurrentCamera_upvr (readonly)
		[5]: HumanoidRootPart_upvw (read and write)
		[6]: Character_upvw (read and write)
	]]
	-- KONSTANTWARNING: Variable analysis failed. Output will have some incorrect variable assignments
	local var43_upvw = 20
	local const_number_upvw = 5
	local clone_2 = Weather_upvr.RainLoop:Clone()
	clone_2.Parent = arg1
	clone_2.Playing = true
	local Folder_upvr = Instance.new("Folder", workspace.Projectiles)
	Folder_upvr.Name = "RainFolder"
	var4_upvw = true
	local tbl_upvr = {}
	local Y_upvr = arg1:GetPivot().Position.Y
	local UpVector_upvr = CFrame.Angles(0, 0, 0.3).UpVector
	local function CreateRainPart_upvr(arg1_2) -- Line 115, Named "CreateRainPart"
		--[[ Upvalues[6]:
			[1]: arg1 (readonly)
			[2]: UpVector_upvr (readonly)
			[3]: Weather_upvr (copied, readonly)
			[4]: var43_upvw (read and write)
			[5]: Value_upvw (copied, read and write)
			[6]: Folder_upvr (readonly)
		]]
		local RaycastParams_new_result1 = RaycastParams.new()
		local tbl = {}
		tbl[1] = arg1
		RaycastParams_new_result1.FilterDescendantsInstances = tbl
		RaycastParams_new_result1.FilterType = Enum.RaycastFilterType.Include
		RaycastParams_new_result1.IgnoreWater = true
		RaycastParams_new_result1.RespectCanCollide = true
		local var52 = arg1_2 + UpVector_upvr * Vector3.new(1, 0, 1) * 500
		local workspace_Raycast_result1 = workspace:Raycast(var52 + Vector3.new(0, 500, 0), UpVector_upvr * -1000, RaycastParams_new_result1)
		local clone = Weather_upvr.RainPart:Clone()
		clone.Size = Vector3.new(var43_upvw, 1, var43_upvw)
		if 7 < Value_upvw then
			clone.Rain.Rate = 30
		else
			clone.Rain.Rate = 50
		end
		if workspace_Raycast_result1 then
			local clone_3 = Weather_upvr.SplashPart:Clone()
			clone_3.CFrame = CFrame.new(workspace_Raycast_result1.Position)
			clone_3.Size = Vector3.new(var43_upvw, 1, var43_upvw)
			clone_3.Parent = clone
			if 7 < Value_upvw then
				clone_3.Splash.Rate = 30
			else
				clone_3.Splash.Rate = 80
			end
			clone.CFrame = CFrame.new(workspace_Raycast_result1.Position + UpVector_upvr * 194, workspace_Raycast_result1.Position) * CFrame.Angles((math.pi/2), 0, 0)
			clone.Parent = Folder_upvr
			return clone
		end
		clone.CFrame = CFrame.new(var52 + UpVector_upvr * 194, var52) * CFrame.Angles((math.pi/2), 0, 0)
		clone.Parent = Folder_upvr
		return clone
	end
	local function _(arg1_3) -- Line 151, Named "MakeRainGrid"
		--[[ Upvalues[5]:
			[1]: const_number_upvw (read and write)
			[2]: var43_upvw (read and write)
			[3]: tbl_upvr (readonly)
			[4]: CreateRainPart_upvr (readonly)
			[5]: Y_upvr (readonly)
		]]
		task.spawn(function() -- Line 152
			--[[ Upvalues[6]:
				[1]: arg1_3 (read and write)
				[2]: const_number_upvw (copied, read and write)
				[3]: var43_upvw (copied, read and write)
				[4]: tbl_upvr (copied, readonly)
				[5]: CreateRainPart_upvr (copied, readonly)
				[6]: Y_upvr (copied, readonly)
			]]
			arg1_3 *= Vector3.new(1, 0, 1)
			for i_3 = -const_number_upvw, const_number_upvw do
				for i_4 = -const_number_upvw, const_number_upvw do
					local vector3 = Vector3.new(math.round((arg1_3.X + i_3 * var43_upvw) / var43_upvw) * var43_upvw, 0, math.round((arg1_3.Z + i_4 * var43_upvw) / var43_upvw) * var43_upvw)
					if not tbl_upvr[vector3] and (vector3 - arg1_3).Magnitude < 100 then
						tbl_upvr[vector3] = CreateRainPart_upvr(vector3 + Vector3.new(0, Y_upvr, 0))
					end
				end
			end
		end)
	end
	local function ClearOOS_upvr() -- Line 168, Named "ClearOOS"
		--[[ Upvalues[3]:
			[1]: tbl_upvr (readonly)
			[2]: CurrentCamera_upvr (copied, readonly)
			[3]: HumanoidRootPart_upvw (copied, read and write)
		]]
		for i_5, v_3 in tbl_upvr do
			if 120 <= (i_5 - CurrentCamera_upvr.CFrame.Position * Vector3.new(1, 0, 1)).Magnitude and 120 <= (i_5 - HumanoidRootPart_upvw.Position * Vector3.new(1, 0, 1)).Magnitude then
				v_3:Destroy()
				tbl_upvr[i_5] = nil
			end
		end
	end
	local Position_upvw = CurrentCamera_upvr.CFrame.Position
	repeat
		task.wait(0.2)
		local var69_upvw
		if 7 < Value_upvw then
			var43_upvw = 10
			var69_upvw = 5
		else
			var43_upvw = 20
			var69_upvw = 3
		end
		if Value_upvw < 5 then
			for i_8, v_4 in tbl_upvr do
				v_4:Destroy()
				tbl_upvr[i_8] = nil
				clone_2.Playing = false
			end
		else
			clone_2.Playing = true
			if Character_upvw:IsDescendantOf(workspace) then
				local Position_upvw_3 = HumanoidRootPart_upvw.Position
				task.spawn(function() -- Line 152
					--[[ Upvalues[6]:
						[1]: Position_upvw_3 (read and write)
						[2]: var69_upvw (read and write)
						[3]: var43_upvw (read and write)
						[4]: tbl_upvr (readonly)
						[5]: CreateRainPart_upvr (readonly)
						[6]: Y_upvr (readonly)
					]]
					Position_upvw_3 *= Vector3.new(1, 0, 1)
					for i_9 = -var69_upvw, var69_upvw do
						for i_10 = -var69_upvw, var69_upvw do
							local vector3_2 = Vector3.new(math.round((Position_upvw_3.X + i_9 * var43_upvw) / var43_upvw) * var43_upvw, 0, math.round((Position_upvw_3.Z + i_10 * var43_upvw) / var43_upvw) * var43_upvw)
							if not tbl_upvr[vector3_2] and (vector3_2 - Position_upvw_3).Magnitude < 100 then
								tbl_upvr[vector3_2] = CreateRainPart_upvr(vector3_2 + Vector3.new(0, Y_upvr, 0))
							end
						end
					end
				end)
			end
			task.wait(1)
		end
	until not var4_upvw and not arg1:IsDescendantOf(workspace)
	var4_upvw = false
	Folder_upvr:Destroy()
	CurrentCamera_upvr:GetPropertyChangedSignal("CFrame"):Connect(function() -- Line 179
		--[[ Upvalues[9]:
			[1]: Position_upvw (read and write)
			[2]: CurrentCamera_upvr (copied, readonly)
			[3]: Value_upvw (copied, read and write)
			[4]: ClearOOS_upvr (readonly)
			[5]: const_number_upvw (read and write)
			[6]: var43_upvw (read and write)
			[7]: tbl_upvr (readonly)
			[8]: CreateRainPart_upvr (readonly)
			[9]: Y_upvr (readonly)
		]]
		if 3 <= (Position_upvw - CurrentCamera_upvr.CFrame.Position).Magnitude and 5 <= Value_upvw then
			ClearOOS_upvr()
			local Position_upvw_2 = CurrentCamera_upvr.CFrame.Position
			task.spawn(function() -- Line 152
				--[[ Upvalues[6]:
					[1]: Position_upvw_2 (read and write)
					[2]: const_number_upvw (copied, read and write)
					[3]: var43_upvw (copied, read and write)
					[4]: tbl_upvr (copied, readonly)
					[5]: CreateRainPart_upvr (copied, readonly)
					[6]: Y_upvr (copied, readonly)
				]]
				Position_upvw_2 *= Vector3.new(1, 0, 1)
				for i_6 = -const_number_upvw, const_number_upvw do
					for i_7 = -const_number_upvw, const_number_upvw do
						local vector3_3 = Vector3.new(math.round((Position_upvw_2.X + i_6 * var43_upvw) / var43_upvw) * var43_upvw, 0, math.round((Position_upvw_2.Z + i_7 * var43_upvw) / var43_upvw) * var43_upvw)
						if not tbl_upvr[vector3_3] and (vector3_3 - Position_upvw_2).Magnitude < 100 then
							tbl_upvr[vector3_3] = CreateRainPart_upvr(vector3_3 + Vector3.new(0, Y_upvr, 0))
						end
					end
				end
			end)
			Position_upvw = CurrentCamera_upvr.CFrame.Position
		end
	end):Disconnect()
	clone_2:Destroy()
end
local tbl_3_upvr = {
	LightFoM = function(arg1, arg2) -- Line 54, Named "LightFoM"
		--[[ Upvalues[1]:
			[1]: TweenService_upvr (readonly)
		]]
		for _, v in arg1 do
			local PointLight_upvr = v.Offset.PointLight
			if arg2 then
				PointLight_upvr.Brightness = 0
				TweenService_upvr:Create(PointLight_upvr, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
					Brightness = 0.05;
				}):Play()
				PointLight_upvr.Enabled = true
			else
				TweenService_upvr:Create(PointLight_upvr, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {
					Brightness = 0;
				}):Play()
				local Brightness_upvr = PointLight_upvr.Brightness
				task.delay(3, function() -- Line 66
					--[[ Upvalues[2]:
						[1]: PointLight_upvr (readonly)
						[2]: Brightness_upvr (readonly)
					]]
					PointLight_upvr.Brightness = Brightness_upvr
					PointLight_upvr.Enabled = false
				end)
			end
		end
	end;
	StartRain = StartRain;
	EndRain = function() -- Line 216, Named "EndRain"
		--[[ Upvalues[1]:
			[1]: var4_upvw (read and write)
		]]
		var4_upvw = false
	end;
	LightMS = function(arg1, arg2) -- Line 74, Named "LightMS"
		--[[ Upvalues[1]:
			[1]: TweenService_upvr (readonly)
		]]
		for _, v_2 in {arg1.LanternLeft, arg1.LanternRight} do
			local FullLight = v_2.Candle.Wick.LitA.FullLight
			local LightShadow_2 = v_2.Candle.Wick.LitA.LightShadow
			if arg2 then
				FullLight.Brightness = 0
				LightShadow_2.Brightness = 0
				TweenService_upvr:Create(FullLight, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
					Brightness = 0.3;
				}):Play()
				TweenService_upvr:Create(LightShadow_2, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
					Brightness = 2;
				}):Play()
			else
				TweenService_upvr:Create(FullLight, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
					Brightness = 0;
				}):Play()
				TweenService_upvr:Create(LightShadow_2, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
					Brightness = 0;
				}):Play()
			end
		end
		local LightShadow = arg1.Candle.Wick.LightOffset.LightShadow
		if arg2 then
			LightShadow.Brightness = 0
			TweenService_upvr:Create(LightShadow, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
				Brightness = 1;
			}):Play()
		else
			TweenService_upvr:Create(LightShadow, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
				Brightness = 0;
			}):Play()
		end
	end;
}
local ClockTime_upvw = Lighting_upvr.ClockTime
Lighting_upvr:WaitForChild("SyncTime").Changed:Connect(function() -- Line 229
	--[[ Upvalues[4]:
		[1]: Lighting_upvr (readonly)
		[2]: Value_upvw (read and write)
		[3]: ClockTime_upvw (read and write)
		[4]: TweenTime_upvr (readonly)
	]]
	local ClockTime = Lighting_upvr.ClockTime
	if Value_upvw < 4 then
		ClockTime_upvw = ClockTime
	else
		if ClockTime - ClockTime_upvw < 0 then
			Lighting_upvr.ClockTime = 0
			ClockTime_upvw = 0
		end
		TweenTime_upvr(ClockTime_upvw, ClockTime)
		ClockTime_upvw = ClockTime
	end
end)
ReplicatedStorage:WaitForChild("Remotes").Map.WeatherEvent.OnClientEvent:Connect(function(arg1, ...) -- Line 243
	--[[ Upvalues[1]:
		[1]: tbl_3_upvr (readonly)
	]]
	if tbl_3_upvr[arg1] then
		tbl_3_upvr[arg1](...)
	end
end)
SettingsModule_upvr:ListenForSetting("NewLighting"):Connect(function() -- Line 249
	--[[ Upvalues[2]:
		[1]: SettingsModule_upvr (readonly)
		[2]: Lighting_upvr (readonly)
	]]
	if SettingsModule_upvr.NewLighting then
		Lighting_upvr.EnvironmentSpecularScale = 1
	else
		Lighting_upvr.EnvironmentSpecularScale = 0.5
	end
end)
if SettingsModule_upvr.NewLighting then
	Lighting_upvr.EnvironmentSpecularScale = 1
else
	Lighting_upvr.EnvironmentSpecularScale = 0.5
end
local CurrentMap = workspace:WaitForChild("CurrentMap", 3)
if CurrentMap then
	local WeatherState = CurrentMap:FindFirstChild("WeatherState")
	if not WeatherState then return end
	if WeatherState.Value == "Rain" then
		task.wait(2)
		StartRain(CurrentMap)
	end
end
Assistant:
Assistant: