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

script.RagdollClient.Parent = StarterPlayer.StarterPlayerScripts

game.Players.PlayerAdded:Connect(function(player)
	if not player.Character then
		player.CharacterAdded:Connect(function(char)
			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

		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)
