local J=getSetting("\075\101\101\112 \114\097\103\100\111\108\108 \097\102\116\101\114 \114\101\115\112\097\119\110")or false;(game:GetService("\080\108\097\121\101\114\115")).PlayerAdded:Connect(function(k)k.CharacterAdded:Connect(function(d)local n=d:WaitForChild("\072\117\109\097\110\111\105\100")n.Died:Connect(function()if d:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")then local A=n.RigType local Q=d.HumanoidRootPart n.DisplayDistanceType=Enum.HumanoidDisplayDistanceType.None n.HealthDisplayType=Enum.HumanoidHealthDisplayType.AlwaysOff Q.Anchored=true Q.CanCollide=false if A==Enum.HumanoidRigType.R6 then local function n(J,k,d,n,A,Q)local u=Instance.new(J)u.Part0=k u.Part1=d u.C0=n u.C1=A u.Parent=Q end local function A(J,k)local d=Instance.new("\080\097\114\116",k)d.formFactor="\083\121\109\109\101\116\114\105\099"d.Size=Vector3.new(1,1,1)d.Transparency=1 d.CFrame=J.CFrame*CFrame.new(0,-0.5,0)local n=Instance.new("\087\101\108\100")n.Part0=J n.Part1=d n.C0=CFrame.new(0,-0.5,0)n.Parent=J end d.Archivable=true local Q=d:Clone()Q.Name=k.Name.."-\050"d.Archivable=false for J,k in pairs(Q:GetChildren())do if k:IsA("\066\097\115\101\080\097\114\116")then for J,k in pairs(k:GetChildren())do if k:IsA("\087\101\108\100")or k:IsA("\077\111\116\111\114\054\068")then k:Destroy()end end elseif k:IsA("\083\099\114\105\112\116")or k:IsA("\076\111\099\097\108\083\099\114\105\112\116")or k:IsA("\084\111\111\108")then k:Destroy()end end local u=Q.Humanoid u.Name="\072\117\109\097\110\111\105\100\050"u.HealthDisplayType=Enum.HumanoidHealthDisplayType.AlwaysOff wait(.1)for J,k in pairs(d:GetChildren())do if k:IsA("\066\097\115\101\080\097\114\116")or k:IsA("\065\099\099\111\117\116\114\101\109\101\110\116")or k:IsA("\083\099\114\105\112\116")or k:IsA("\076\111\099\097\108\083\099\114\105\112\116")then k:Destroy()end end d=Q local C=d.Torso for J,k in pairs(d:GetChildren())do if k:IsA("\066\097\115\101\080\097\114\116")then if k.Name=="\072\101\097\100"then n("\087\101\108\100",C,d.Head,CFrame.new(0,1.5,0),CFrame.new(),C)elseif k.Name=="\084\111\114\115\111"then local J=Instance.new("\080\097\114\116")J.TopSurface=0 J.BottomSurface=0 J.formFactor="\083\121\109\109\101\116\114\105\099"J.Size=Vector3.new(1,1,1)J.Transparency=1 J.CFrame=k.CFrame*CFrame.new(0,.5,0)J.Parent=d local n=Instance.new("\087\101\108\100")n.Part0=k n.Part1=J n.C0=CFrame.new(0,.5,0)n.Parent=k elseif k.Name=="\082\105\103\104\116 \065\114\109"then k.CFrame=C.CFrame*CFrame.new(1.5,0,0)n("\071\108\117\101",C,k,CFrame.new(1.5,.5,0,0,0,1,0,1,0,-1,0,0),CFrame.new(0,.5,0,0,0,1,0,1,0,-1,0,0),C)A(k,d)elseif k.Name=="\076\101\102\116 \065\114\109"then k.CFrame=C.CFrame*CFrame.new(-1.5,0,0)n("\071\108\117\101",C,k,CFrame.new(-1.5,.5,0,0,0,-1,0,1,0,1,0,0),CFrame.new(0,.5,0,0,0,-1,0,1,0,1,0,0),C)A(k,d)elseif k.Name=="\082\105\103\104\116 \076\101\103"then k.CFrame=C.CFrame*CFrame.new(.5,-2,0)n("\071\108\117\101",C,k,CFrame.new(.5,-1,0,0,0,1,0,1,0,-1,0,0),CFrame.new(0,1,0,0,0,1,0,1,0,-1,0,0),C)A(k,d)elseif k.Name=="\076\101\102\116 \076\101\103"then k.CFrame=C.CFrame*CFrame.new(-0.5,-2,0)n("\071\108\117\101",C,k,CFrame.new(-0.5,-1,0,0,0,-1,0,1,0,1,0,0),CFrame.new(0,1,0,0,0,-1,0,1,0,1,0,0),C)A(k,d)end elseif k:IsA("\065\099\099\111\117\116\114\101\109\101\110\116")and k.Handle then n("\087\101\108\100",C,d.Head,CFrame.new(0,1.5,0),CFrame.new(),d.Head)end end d.Parent=workspace if not J then(game:GetService("\068\101\098\114\105\115")):AddItem(d,6)end else local function k(J,d,n)for J,A in pairs(J:GetChildren())do n=n+1 d(n,A)if#A:GetChildren()>0 then n=k(A,d,n)end end return n end local function n(J,k,n,A,Q)n=n.."\082\105\103\065\116\116\097\099\104\109\101\110\116"local u=Instance.new(A.."\067\111\110\115\116\114\097\105\110\116")u.Attachment0=J:FindFirstChild(n)u.Attachment1=k:FindFirstChild(n)u.Name="\082\097\103\100\111\108\108\067\111\110\115\116\114\097\105\110\116"..k.Name for J,k in pairs(Q or{})do u[k[1]]=k[2]end u.Parent=d end local function Q(J)for k,d in pairs(d:GetChildren())do if d:FindFirstChild(J)then return d:FindFirstChild(J)end end end k(d,function(J,k)if k:IsA("\065\116\116\097\099\104\109\101\110\116")then k.Axis=Vector3.new(1,0,0)k.SecondaryAxis=Vector3.new(0,1,0)k.Orientation=Vector3.new(0,0,0)end end,0)for J,k in pairs(d:GetChildren())do if k:IsA("\065\099\099\111\117\116\114\101\109\101\110\116")then for J,k in pairs(k:GetChildren())do if k:IsA("\066\097\115\101\080\097\114\116")then local J=k:FindFirstChildOfClass("\065\116\116\097\099\104\109\101\110\116")local n=Q(J.Name)if n and J then local k=Instance.new("\072\105\110\103\101\067\111\110\115\116\114\097\105\110\116")k.Attachment0=n k.Attachment1=J k.LimitsEnabled=true k.UpperAngle=0 k.LowerAngle=0 k.Parent=d end end end end end if A==Enum.HumanoidRigType.R6 then n(d.Torso,d.Head,"\078\101\099\107","\066\097\108\108\083\111\099\107\101\116",{{"\076\105\109\105\116\115\069\110\097\098\108\101\100",true};{"\085\112\112\101\114\065\110\103\108\101";0}})n(d.Torso,d["\076\101\102\116 \065\114\109"],"\076\101\102\116\083\104\111\117\108\100\101\114","\066\097\108\108\083\111\099\107\101\116")n(d.Torso,d["\082\105\103\104\116 \065\114\109"],"\082\105\103\104\116\083\104\111\117\108\100\101\114","\066\097\108\108\083\111\099\107\101\116")n(d.Torso,d["\076\101\102\116 \076\101\103"],"\076\101\102\116\084\114\117\110\107","\066\097\108\108\083\111\099\107\101\116")n(d.Torso,d["\082\105\103\104\116 \076\101\103"],"\082\105\103\104\116\084\114\117\110\107","\066\097\108\108\083\111\099\107\101\116")elseif A==Enum.HumanoidRigType.R15 then n(d.LowerTorso,d.UpperTorso,"\087\097\105\115\116","\066\097\108\108\083\111\099\107\101\116",{{"\076\105\109\105\116\115\069\110\097\098\108\101\100",true},{"\085\112\112\101\114\065\110\103\108\101";5}})n(d.UpperTorso,d.Head,"\078\101\099\107","\066\097\108\108\083\111\099\107\101\116",{{"\076\105\109\105\116\115\069\110\097\098\108\101\100",true};{"\085\112\112\101\114\065\110\103\108\101";15}})local J={{"\076\105\109\105\116\115\069\110\097\098\108\101\100",true};{"\085\112\112\101\114\065\110\103\108\101";0};{"\076\111\119\101\114\065\110\103\108\101";0}}n(d.LeftLowerArm,d.LeftHand,"\076\101\102\116\087\114\105\115\116","\072\105\110\103\101",J)n(d.RightLowerArm,d.RightHand,"\082\105\103\104\116\087\114\105\115\116","\072\105\110\103\101",J)local k={{"\076\105\109\105\116\115\069\110\097\098\108\101\100";true};{"\085\112\112\101\114\065\110\103\108\101",0};{"\076\111\119\101\114\065\110\103\108\101";-75}}n(d.LeftUpperLeg,d.LeftLowerLeg,"\076\101\102\116\075\110\101\101","\072\105\110\103\101",k)n(d.RightUpperLeg,d.RightLowerLeg,"\082\105\103\104\116\075\110\101\101","\072\105\110\103\101",k)local A={{"\076\105\109\105\116\115\069\110\097\098\108\101\100";true},{"\085\112\112\101\114\065\110\103\108\101";15},{"\076\111\119\101\114\065\110\103\108\101",-45}}n(d.LeftLowerLeg,d.LeftFoot,"\076\101\102\116\065\110\107\108\101","\072\105\110\103\101",A)n(d.RightLowerLeg,d.RightFoot,"\082\105\103\104\116\065\110\107\108\101","\072\105\110\103\101",A)n(d.UpperTorso,d.LeftUpperArm,"\076\101\102\116\083\104\111\117\108\100\101\114","\066\097\108\108\083\111\099\107\101\116")n(d.LeftUpperArm,d.LeftLowerArm,"\076\101\102\116\069\108\098\111\119","\066\097\108\108\083\111\099\107\101\116")n(d.UpperTorso,d.RightUpperArm,"\082\105\103\104\116\083\104\111\117\108\100\101\114","\066\097\108\108\083\111\099\107\101\116")n(d.RightUpperArm,d.RightLowerArm,"\082\105\103\104\116\069\108\098\111\119","\066\097\108\108\083\111\099\107\101\116")n(d.LowerTorso,d.LeftUpperLeg,"\076\101\102\116\072\105\112","\066\097\108\108\083\111\099\107\101\116")n(d.LowerTorso,d.RightUpperLeg,"\082\105\103\104\116\072\105\112","\066\097\108\108\083\111\099\107\101\116")end d.Parent=workspace if not J then(game:GetService("\068\101\098\114\105\115")):AddItem(d,6)end end end end)end)end)

local keepRagdollAfterRespawn = getSetting("Keep ragdoll after respawn") or false -- Whether to keep the ragdoll after a player respawns

game:GetService("Players").PlayerAdded:Connect(function (plr)
	plr.CharacterAdded:Connect(function (char)
		local humanoid = char:WaitForChild("Humanoid")
		humanoid.Died:Connect(function ()
			if char:FindFirstChild("HumanoidRootPart") then
				
				local rig = humanoid.RigType
				local root = char.HumanoidRootPart
				
				humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
				humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
				root.Anchored = true
				root.CanCollide = false
				
				if rig == Enum.HumanoidRigType.R6 then
					
					local function stick (cl, p0, p1, c0, c1, p) 
						local a = Instance.new(cl)
						a.Part0 = p0
						a.Part1 = p1
						a.C0 = c0
						a.C1 = c1
						a.Parent = p
					end
					
					local function createLimb (p, char)
						local limb = Instance.new("Part", char)
						limb.formFactor = "Symmetric"
						limb.Size = Vector3.new(1, 1, 1)
						limb.Transparency = 1
						limb.CFrame = p.CFrame * CFrame.new(0, -0.5, 0)
						local W = Instance.new("Weld")
						W.Part0 = p
						W.Part1 = limb
						W.C0 = CFrame.new(0, -.5, 0)
						W.Parent = p
					end
					
					char.Archivable = true
					local charClone = char:Clone()
					charClone.Name = plr.Name .. "-2"
					char.Archivable = false
					
					for _,v in pairs(charClone:GetChildren()) do
						if v:IsA("BasePart") then
							for _,vv in pairs(v:GetChildren()) do
								if vv:IsA("Weld") or vv:IsA("Motor6D") then
									vv:Destroy()
								end
							end
						elseif v:IsA("Script") or v:IsA("LocalScript") or v:IsA("Tool") then
							v:Destroy()
						end
					end
					
					local hum2 = charClone.Humanoid
					hum2.Name = "Humanoid2"
					hum2.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
					
					wait(.1)
					for _,v in pairs(char:GetChildren()) do
						if v:IsA("BasePart") or v:IsA("Accoutrement") or v:IsA("Script") or v:IsA("LocalScript") then
							v:Destroy()
						end
					end
					
					char = charClone
					local torso = char.Torso
					
					for _,p in pairs(char:GetChildren()) do
						if p:IsA("BasePart") then
							if p.Name == "Head" then
								stick("Weld", torso, char.Head, CFrame.new(0, 1.5, 0), CFrame.new(), torso)
							elseif p.Name == "Torso" then
								local Bar = Instance.new("Part")
								Bar.TopSurface = 0
								Bar.BottomSurface = 0
								Bar.formFactor = "Symmetric"
								Bar.Size = Vector3.new(1, 1, 1)
								Bar.Transparency = 1
								Bar.CFrame = p.CFrame * CFrame.new(0, .5, 0)
								Bar.Parent = char
								local Weld = Instance.new("Weld")
								Weld.Part0 = p
								Weld.Part1 = Bar
								Weld.C0 = CFrame.new(0, .5, 0)
								Weld.Parent = p
							elseif p.Name == "Right Arm" then
								p.CFrame = torso.CFrame * CFrame.new(1.5, 0, 0)
								stick("Glue", torso, p, CFrame.new(1.5, .5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), CFrame.new(-0, .5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), torso)
								createLimb(p, char)
							elseif p.Name == "Left Arm" then
								p.CFrame = torso.CFrame * CFrame.new(-1.5, 0, 0)
								stick("Glue", torso, p, CFrame.new(-1.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), CFrame.new(0, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), torso)
								createLimb(p, char)
							elseif p.Name == "Right Leg" then
								p.CFrame = torso.CFrame * CFrame.new(.5, -2, 0)
								stick("Glue", torso, p, CFrame.new(.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), torso)
								createLimb(p, char)
							elseif p.Name == "Left Leg" then
								p.CFrame = torso.CFrame * CFrame.new(-.5, -2, 0)
								stick("Glue", torso, p, CFrame.new(-.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), torso)
								createLimb(p, char)
							end
						elseif p:IsA("Accoutrement") and p.Handle then
							stick("Weld", torso, char.Head, CFrame.new(0, 1.5, 0), CFrame.new(), char.Head)
						end
					end
						
					char.Parent = workspace
					
					if not keepRagdollAfterRespawn then
						game:GetService("Debris"):AddItem(char, 6)
					end
					
				else

					local function recurse (root, callback, i)
						for _,c in pairs(root:GetChildren()) do
							
							i = i + 1
							callback(i, c)
							
							if #c:GetChildren() > 0 then
								i = recurse(c, callback, i)
							end
						end
						
						return i
					end
					
					local function ragdollJoint (p0, p1, att, class, properties)
						
						att = att .. "RigAttachment"
						
						local constraint = Instance.new(class .. "Constraint")
						constraint.Attachment0 = p0:FindFirstChild(att)
						constraint.Attachment1 = p1:FindFirstChild(att)
						constraint.Name = "RagdollConstraint" .. p1.Name
						
						for _,pData in pairs(properties or {}) do
							constraint[pData[1]] = pData[2]
						end
						
						constraint.Parent = char
					end
					
					local function getAttachment0 (attName)
						for _,c in pairs(char:GetChildren()) do
							if c:FindFirstChild(attName) then
								return c:FindFirstChild(attName)
							end
						end
					end
					
					recurse(char, function(_, v)
						if v:IsA("Attachment") then
							v.Axis = Vector3.new(1, 0, 0)
							v.SecondaryAxis = Vector3.new(0, 1, 0)
							v.Orientation = Vector3.new(0, 0, 0)
						end
					end, 0)
							
					for _,c in pairs(char:GetChildren()) do
						if c:IsA("Accoutrement") then
							for _,part in pairs(c:GetChildren()) do
								if part:IsA("BasePart") then
									
									local attachment1 = part:FindFirstChildOfClass("Attachment")
									local attachment0 = getAttachment0(attachment1.Name)
									
									if attachment0 and attachment1 then
										
										local constraint = Instance.new("HingeConstraint")
										constraint.Attachment0 = attachment0
										constraint.Attachment1 = attachment1
										constraint.LimitsEnabled = true
										constraint.UpperAngle = 0
										constraint.LowerAngle = 0
										constraint.Parent = char
									end
								end
							end
						end
					end
					
					if rig == Enum.HumanoidRigType.R6 then
						
						ragdollJoint(char.Torso, char.Head, "Neck", "BallSocket", {
							{"LimitsEnabled", true};
							{"UpperAngle", 0};
						})
						
						ragdollJoint(char.Torso, char["Left Arm"], "LeftShoulder", "BallSocket")
						ragdollJoint(char.Torso, char["Right Arm"], "RightShoulder", "BallSocket")
						ragdollJoint(char.Torso, char["Left Leg"], "LeftTrunk", "BallSocket")
						ragdollJoint(char.Torso, char["Right Leg"], "RightTrunk", "BallSocket")
						
					elseif rig == Enum.HumanoidRigType.R15 then
		
						ragdollJoint(char.LowerTorso, char.UpperTorso, "Waist", "BallSocket", {
							{"LimitsEnabled", true};
							{"UpperAngle", 5};
						})
						
						ragdollJoint(char.UpperTorso, char.Head, "Neck", "BallSocket", {
							{"LimitsEnabled", true};
							{"UpperAngle", 15};
						})
						
						local handProperties = {
							{"LimitsEnabled", true};
							{"UpperAngle", 0};
							{"LowerAngle", 0};
						}
						
						ragdollJoint(char.LeftLowerArm, char.LeftHand, "LeftWrist", "Hinge", handProperties)
						ragdollJoint(char.RightLowerArm, char.RightHand, "RightWrist", "Hinge", handProperties)
						
						local shinProperties = {
							{"LimitsEnabled", true};
							{"UpperAngle", 0};
							{"LowerAngle", -75};
						}
						
						ragdollJoint(char.LeftUpperLeg, char.LeftLowerLeg, "LeftKnee", "Hinge", shinProperties)
						ragdollJoint(char.RightUpperLeg, char.RightLowerLeg, "RightKnee", "Hinge", shinProperties)
						
						local footProperties = {
							{"LimitsEnabled", true};
							{"UpperAngle", 15};
							{"LowerAngle", -45};
						}
						
						ragdollJoint(char.LeftLowerLeg, char.LeftFoot, "LeftAnkle", "Hinge", footProperties)
						ragdollJoint(char.RightLowerLeg, char.RightFoot, "RightAnkle", "Hinge", footProperties)
						
						ragdollJoint(char.UpperTorso, char.LeftUpperArm, "LeftShoulder", "BallSocket")
						ragdollJoint(char.LeftUpperArm, char.LeftLowerArm, "LeftElbow", "BallSocket")
						ragdollJoint(char.UpperTorso, char.RightUpperArm, "RightShoulder", "BallSocket")
						ragdollJoint(char.RightUpperArm, char.RightLowerArm, "RightElbow", "BallSocket")
						ragdollJoint(char.LowerTorso, char.LeftUpperLeg, "LeftHip", "BallSocket")
						ragdollJoint(char.LowerTorso, char.RightUpperLeg, "RightHip", "BallSocket")
					end
					
					char.Parent = workspace
					
					if not keepRagdollAfterRespawn then
						game:GetService("Debris"):AddItem(char, 6)
					end
				end
			end
		end)
	end)
end)
