local N=script.RagdollParts script.RagdollClient.Parent=StarterPlayer.StarterCharacterScripts game.Players.PlayerAdded:Connect(function(F)if not F.Character then F.CharacterAdded:Connect(function(F)if F:FindFirstChild("\085\112\112\101\114\084\111\114\115\111")then return end local O={}for N,F in pairs(N:GetChildren())do O[F.Name]=F:Clone()end for N,l in pairs(O)do if l:IsA("\065\116\116\097\099\104\109\101\110\116")then l.Parent=F[l:GetAttribute("\080\097\114\101\110\116")]elseif l:IsA("\066\097\108\108\083\111\099\107\101\116\067\111\110\115\116\114\097\105\110\116")then l.Parent=F.Torso l.Attachment0=O[l:GetAttribute("\048")]l.Attachment1=O[l:GetAttribute("\049")]else l.Part0=F.HumanoidRootPart l.Part1=F.Torso l.Parent=F.HumanoidRootPart end end end)else local O=F.Character if O:FindFirstChild("\085\112\112\101\114\084\111\114\115\111")then return end local l={}for N,F in pairs(N:GetChildren())do l[F.Name]=F:Clone()end for N,F in pairs(l)do if F:IsA("\065\116\116\097\099\104\109\101\110\116")then F.Parent=O[F:GetAttribute("\080\097\114\101\110\116")]elseif F:IsA("\066\097\108\108\083\111\099\107\101\116\067\111\110\115\116\114\097\105\110\116")then F.Parent=O.Torso F.Attachment0=l[F:GetAttribute("\048")]F.Attachment1=l[F:GetAttribute("\049")]else F.Part0=O.HumanoidRootPart F.Part1=O.Torso F.Parent=O.HumanoidRootPart end end end end);(CS:GetInstanceAddedSignal("\082\097\103\100\111\108\108")):Connect(function(N)if N:IsA("\077\111\100\101\108")then ragdollBuilder:Ragdoll(N)end end);(CS:GetInstanceRemovedSignal("\082\097\103\100\111\108\108")):Connect(function(N)if N:IsA("\077\111\100\101\108")then ragdollBuilder:Unragdoll(N)end end)
-- MISC VARIABLES --
local ragdollParts = script.RagdollParts

script.RagdollClient.Parent = StarterPlayer.StarterCharacterScripts

game.Players.PlayerAdded:Connect(function(player)
	if not player.Character then
		player.CharacterAdded:Connect(function(char)
			if char:FindFirstChild("UpperTorso") then
				return
			end

			local clones = {}
			for i, v in pairs(ragdollParts:GetChildren()) do
				clones[v.Name] = v:Clone()
			end

			for i, v in pairs(clones) do
				if v:IsA("Attachment") then
					v.Parent = char[v:GetAttribute("Parent")]
				elseif v:IsA("BallSocketConstraint") then
					v.Parent = char.Torso
					v.Attachment0 = clones[v:GetAttribute("0")]
					v.Attachment1 = clones[v:GetAttribute("1")]
				else
					v.Part0 = char.HumanoidRootPart
					v.Part1 = char.Torso
					v.Parent = char.HumanoidRootPart
				end
			end
		end)
	else
		local char = player.Character

		if char:FindFirstChild("UpperTorso") then
			return
		end

		local clones = {}
		for i, v in pairs(ragdollParts:GetChildren()) do
			clones[v.Name] = v:Clone()
		end

		for i, v in pairs(clones) do
			if v:IsA("Attachment") then
				v.Parent = char[v:GetAttribute("Parent")]
			elseif v:IsA("BallSocketConstraint") then
				v.Parent = char.Torso
				v.Attachment0 = clones[v:GetAttribute("0")]
				v.Attachment1 = clones[v:GetAttribute("1")]
			else
				v.Part0 = char.HumanoidRootPart
				v.Part1 = char.Torso
				v.Parent = char.HumanoidRootPart
			end
		end
	end
end)

CS:GetInstanceAddedSignal("Ragdoll"):Connect(function(v)
	if v:IsA("Model") then
		ragdollBuilder:Ragdoll(v)
	end
end)

CS:GetInstanceRemovedSignal("Ragdoll"):Connect(function(v)
	if v:IsA("Model") then
		ragdollBuilder:Unragdoll(v)
	end
end)
