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-04 18:08:41
-- Luau version 6, Types version 3
-- Time taken: 0.007581 seconds

local module_upvr_2 = {}
module_upvr_2.__index = module_upvr_2
local tbl_upvr = {}
local Settings_upvr = require(script.Parent.Settings)
local CharacterSettings_upvr = Settings_upvr.CharacterSettings
local module_upvr = require(script:WaitForChild("Ragdoll"))
function module_upvr_2.Create(arg1) -- Line 15
	--[[ Upvalues[2]:
		[1]: module_upvr_2 (readonly)
		[2]: module_upvr (readonly)
	]]
	local setmetatable_result1 = setmetatable({}, module_upvr_2)
	setmetatable_result1.Character = arg1
	setmetatable_result1.Humanoid = arg1:WaitForChild("Humanoid")
	setmetatable_result1.HumanoidRootPart = arg1:WaitForChild("HumanoidRootPart")
	setmetatable_result1.MyRagdoll = module_upvr.CreateRag(arg1)
	setmetatable_result1.Knocked = false
	setmetatable_result1.KnockedAt = 0
	setmetatable_result1.LastHealth = 0
	setmetatable_result1.GettingGripped = false
	setmetatable_result1.GettingCarried = false
	setmetatable_result1.Gripping = false
	setmetatable_result1.Carrying = false
	setmetatable_result1.CarryWelds = {}
	setmetatable_result1.CarryCooldown = false
	setmetatable_result1.CarryTarget = nil
	setmetatable_result1:Load()
end
function module_upvr_2.SetKnocked(arg1) -- Line 40
	arg1.Knocked = true
	arg1.KnockedAt = tick()
	arg1.MyRagdoll:Build()
end
function module_upvr_2.UnKnock(arg1) -- Line 51
	arg1.Knocked = false
	arg1.MyRagdoll:Destroy()
end
function module_upvr_2.AddToCharacterTable(arg1) -- Line 61
	--[[ Upvalues[1]:
		[1]: tbl_upvr (readonly)
	]]
	tbl_upvr[arg1.Character] = arg1
end
function module_upvr_2.SetCharacterParent(arg1) -- Line 65
	repeat
		wait()
		arg1.Character.Parent = workspace.Characters
	until arg1.Character.Parent == workspace.Characters
end
function module_upvr_2.Load(arg1) -- Line 71
	--[[ Upvalues[3]:
		[1]: CharacterSettings_upvr (readonly)
		[2]: tbl_upvr (readonly)
		[3]: Settings_upvr (readonly)
	]]
	repeat
		wait()
	until arg1.Character:IsDescendantOf(workspace)
	arg1.Humanoid:GetPropertyChangedSignal("Health"):Connect(function() -- Line 73
		--[[ Upvalues[2]:
			[1]: arg1 (readonly)
			[2]: CharacterSettings_upvr (copied, readonly)
		]]
		if not arg1.Knocked and arg1.Humanoid.Health <= CharacterSettings_upvr.KnockAt then
			arg1:SetKnocked()
		end
		if arg1.Knocked then
			if arg1.Humanoid.Health < arg1.LastHealth then
				arg1.KnockedAt = tick()
			end
			arg1.LastHealth = arg1.Humanoid.Health
		else
			arg1.LastHealth = arg1.Humanoid.Health
		end
	end)
	arg1.Humanoid.Died:Connect(function() -- Line 88
		--[[ Upvalues[2]:
			[1]: tbl_upvr (copied, readonly)
			[2]: arg1 (readonly)
		]]
		tbl_upvr[arg1.Character] = nil
		arg1:UnKnock()
	end)
	local Animation_2 = Instance.new("Animation")
	Animation_2.AnimationId = Settings_upvr.GripSelfAnim
	arg1.MyGripAnim = arg1.Humanoid:LoadAnimation(Animation_2)
	arg1.ThereGripAnim = nil
	arg1:AddToCharacterTable()
	arg1.MyGripAnim.Ended:Connect(function() -- Line 100
		--[[ Upvalues[1]:
			[1]: arg1 (readonly)
		]]
		if arg1.LastGrippedPerson then
			arg1.LastGrippedPerson.Humanoid.Health = 0
			arg1.Ended = true
		end
	end)
end
function module_upvr_2.FindNearestDowned(arg1) -- Line 108
	--[[ Upvalues[2]:
		[1]: CharacterSettings_upvr (readonly)
		[2]: tbl_upvr (readonly)
	]]
	local var26
	for _, v in pairs(game.Players:GetPlayers()) do
		if v and v.Character and v.Character:FindFirstChild("Humanoid") then
			v = v.Character
			if v ~= arg1.Character and v:FindFirstChild("HumanoidRootPart") and tbl_upvr[v] and tbl_upvr[v].Knocked and not tbl_upvr[v].GettingCarried and not tbl_upvr[v].GettingGripped and (arg1.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < CharacterSettings_upvr.MaxPickUpRange then
			end
		end
	end
	return nil
end
function module_upvr_2.AddCarryCooldown(arg1) -- Line 130
	--[[ Upvalues[1]:
		[1]: CharacterSettings_upvr (readonly)
	]]
	arg1.CarryCooldown = true
	wait(CharacterSettings_upvr.CarryCooldown)
	arg1.CarryCooldown = false
end
function module_upvr_2.CheckClimbNetworkOwner(arg1, arg2) -- Line 136
	local pairs_result1, pairs_result2_4, pairs_result3_5 = pairs(arg1.Character:GetChildren())
	for _, v_2 in pairs_result1, pairs_result2_4, pairs_result3_5 do
		if v_2:IsA("BasePart") then
			v_2.Anchored = false
			v_2:SetNetworkOwner(game.Players:FindFirstChild(arg1.Character.Name))
			v_2:SetNetworkOwnershipAuto(false)
		end
	end
	pairs_result1 = arg2
	local var38 = pairs_result1
	if not var38 then
		var38 = arg1.CarryTarget
	end
	for _, v_3 in pairs(var38:GetChildren()) do
		if v_3:IsA("BasePart") and not v_3.Anchored and v_3:IsDescendantOf(workspace) then
			v_3.Anchored = false
			v_3:SetNetworkOwner(game.Players:FindFirstChild(arg1.Character.Name))
			v_3:SetNetworkOwnershipAuto(false)
			v_3.CanCollide = false
			v_3.Massless = true
		end
	end
end
function module_upvr_2.CarryAnim(arg1, arg2) -- Line 157
	--[[ Upvalues[1]:
		[1]: Settings_upvr (readonly)
	]]
	if arg2 then
		local Animation = Instance.new("Animation")
		Animation.AnimationId = Settings_upvr.CarryAnim
		local Animation_3 = Instance.new("Animation")
		Animation_3.AnimationId = Settings_upvr.CarrierAnim
		arg1.CarryAnim = arg1.CarryTarget.Humanoid:LoadAnimation(Animation)
		arg1.CarryAnim:Play()
		arg1.CarrierAnim = arg1.Humanoid:LoadAnimation(Animation_3)
		arg1.CarrierAnim:Play()
	end
end
function module_upvr_2.InitCarrying(arg1) -- Line 173
	--[[ Upvalues[1]:
		[1]: tbl_upvr (readonly)
	]]
	if arg1.CarryCooldown then
	else
		if arg1.Knocked then return end
		if arg1.Gripping then return end
		if arg1.Carrying then
			for i_5, v_5 in pairs(arg1.CarryWelds) do
				v_5:Destroy()
			end
			arg1.CarryWelds = {}
			arg1.Carrying = false
			arg1.CarryAnim = nil
			if tbl_upvr[arg1.CarryTarget] then
				i_5 = arg1.CarryTarget
				if tbl_upvr[i_5].Knocked then
					i_5 = arg1.CarryTarget
					tbl_upvr[i_5].MyRagdoll:Destroy()
					tbl_upvr[arg1.CarryTarget].GettingCarried = false
				end
			end
			arg1.CarryTarget.Humanoid.PlatformStand = false
			for _, v_6 in pairs(arg1.CarryTarget.Humanoid:GetPlayingAnimationTracks()) do
				v_6:Stop()
			end
			if arg1.CarrierAnim then
				arg1.CarrierAnim:Stop()
			end
			tbl_upvr[arg1.CarryTarget].MyRagdoll:Destroy()
			game.ReplicatedStorage.CServer:FireClient(game.Players:GetPlayerFromCharacter(arg1.CarryTarget), "ResetAll")
			arg1:AddCarryCooldown()
			return
		end
		local any_FindNearestDowned_result1_upvr = arg1:FindNearestDowned()
		if any_FindNearestDowned_result1_upvr then
			any_FindNearestDowned_result1_upvr.HumanoidRootPart.CFrame = arg1.HumanoidRootPart.CFrame + Vector3.new(0, 1.25, 0)
			any_FindNearestDowned_result1_upvr.HumanoidRootPart.CFrame = any_FindNearestDowned_result1_upvr.HumanoidRootPart.CFrame + any_FindNearestDowned_result1_upvr.HumanoidRootPart.CFrame.RightVector * 0.45 + any_FindNearestDowned_result1_upvr.HumanoidRootPart.CFrame.LookVector * 0.75
			arg1.Carrying = true
			local WeldConstraint = Instance.new("WeldConstraint")
			WeldConstraint.Part0 = arg1.HumanoidRootPart
			WeldConstraint.Part1 = any_FindNearestDowned_result1_upvr.HumanoidRootPart
			WeldConstraint.Parent = arg1.Character
			WeldConstraint.Name = "CarryWeld"
			if tbl_upvr[any_FindNearestDowned_result1_upvr] then
				tbl_upvr[any_FindNearestDowned_result1_upvr].MyRagdoll:Build()
				tbl_upvr[any_FindNearestDowned_result1_upvr].GettingCarried = true
			end
			table.insert(arg1.CarryWelds, WeldConstraint)
			arg1.CarryTarget = any_FindNearestDowned_result1_upvr
			arg1:CheckClimbNetworkOwner()
			arg1:CarryAnim(true)
			task.delay(0.03, function() -- Line 234
				--[[ Upvalues[1]:
					[1]: arg1 (readonly)
				]]
				arg1:CheckClimbNetworkOwner()
			end)
			task.delay(0.3, function() -- Line 238
				--[[ Upvalues[2]:
					[1]: tbl_upvr (copied, readonly)
					[2]: any_FindNearestDowned_result1_upvr (readonly)
				]]
				tbl_upvr[any_FindNearestDowned_result1_upvr].MyRagdoll:Build()
			end)
			arg1:AddCarryCooldown()
		end
	end
end
game:GetService("RunService").Heartbeat:Connect(function(arg1) -- Line 249
	--[[ Upvalues[2]:
		[1]: tbl_upvr (readonly)
		[2]: CharacterSettings_upvr (readonly)
	]]
	for _, v_4 in pairs(tbl_upvr) do
		if 27 <= v_4.Humanoid.Health then
			if v_4.CarryTarget.Humanoid:GetState() ~= Enum.HumanoidStateType.GettingUp then
				game.ReplicatedStorage.CServer:FireClient(game.Players:GetPlayerFromCharacter(v_4.CarryTarget), "upCarry")
				-- KONSTANTWARNING: GOTO [85] #52
			end
		else
			if v_4.Knocked then
				v_4:UnKnock()
			end
			if v_4.Carrying then
				v_4:InitCarrying()
			end
			if v_4.CarryTarget.Humanoid:GetState() ~= Enum.HumanoidStateType.Physics then
				game.ReplicatedStorage.CServer:FireClient(game.Players:GetPlayerFromCharacter(v_4.CarryTarget), "downCarry")
			end
		end
		if v_4.CarryTarget then
			if 27 <= v_4.CarryTarget.Humanoid.Health then
				if v_4.Carrying then
					v_4:InitCarrying()
				end
				if v_4.CarryTarget.Humanoid:GetState() ~= Enum.HumanoidStateType.GettingUp then
					game.ReplicatedStorage.CServer:FireClient(game.Players:GetPlayerFromCharacter(v_4.CarryTarget), "upCarry")
					-- KONSTANTWARNING: GOTO [164] #98
				end
			elseif v_4.CarryTarget.Humanoid:GetState() ~= Enum.HumanoidStateType.Physics then
				game.ReplicatedStorage.CServer:FireClient(game.Players:GetPlayerFromCharacter(v_4.CarryTarget), "downCarry")
			end
		end
		if v_4.GettingGripped or v_4.GettingCarried then
			v_4.KnockedAt = tick()
		end
		if v_4.Knocked and CharacterSettings_upvr.UnKnockAt <= tick() - v_4.KnockedAt then
			v_4:UnKnock()
		end
		if not v_4.Character:IsDescendantOf(workspace) and v_4.Carrying then
			v_4:InitCarrying()
		end
		if v_4.Carrying then
			v_4:CheckClimbNetworkOwner()
			v_4.CarryTarget.Humanoid.PlatformStand = true
		end
	end
end)
game.ReplicatedStorage.Events.Carry.OnServerEvent:Connect(function(arg1) -- Line 309
	--[[ Upvalues[1]:
		[1]: tbl_upvr (readonly)
	]]
	if tbl_upvr[arg1.Character] then
		tbl_upvr[arg1.Character]:InitCarrying()
	end
end)
_G.AllLoadedCharacters = tbl_upvr
return module_upvr_2
Assistant:
Assistant: