How to Make Ragdoll more efficient

wait(2)
local char = script.Parent
local hum = char.Humanoid
local root = char.HumanoidRootPart
function weldTogether(p12, p13)
	local v13 = Instance.new("Weld");
	v13.Part0 = p12;
	v13.Part1 = p13;
	local v14 = CFrame.new(p12.Position);
	v13.C0 = p12.CFrame:inverse() * v14;
	v13.C1 = p13.CFrame:inverse() * v14;
	v13.Parent = p12;
end;
local glue = {}
function ragdollClone(p14)
	local v15, v16, v17 = pairs((p14:GetChildren()));
	while true do
		local v18, v19 = v15(v16, v17);
		if v18 then

		else
			break;
		end;
		v17 = v18;
		if v19:IsA("BasePart") then
			local v20 = v19:Clone();
			v20:ClearAllChildren();
			v20.Transparency = 1;
			v20.Name = "Bone";
			v20.Size = v20.Size * 0.5;
			v20.CanCollide = true;
			weldTogether(v20, v19);
			v20.Parent = v19;
		end;	
	end;
	local v21, v22, v23 = pairs((p14.Torso:GetChildren()));
	while true do
		local v24, v25 = v21(v22, v23);
		if v24 then

		else
			break
		end
		v23 = v24
		if v25:IsA("Motor6D") then
			local v26 = Instance.new("Glue")
			v26.Part0 = v25.Part0
			v26.Part1 = v25.Part1
			v26.C0 = v25.C0
			v26.Name = "Glue" .. v25.Name
			v26.C1 = v25.C1
			v26.Parent = v25.Parent
			v25.Part0 = nil
		end;	
	end;
	hum.PlatformStand = true;
end;
char.Ragdoll.Changed:Connect(function(new)
	if new == true then
		ragdollClone(char)
	else
		for a,b in pairs(char.Torso:GetChildren()) do
			if b:IsA('Motor6D') then
				b.Part0 = char.Torso
			end
		end
		for a,b in pairs(char:GetDescendants()) do
			if b.Name == 'Bone' or b.Name:match('Glue') then
				b:Destroy()
			end
		end
		hum.PlatformStand = false
	end
end)

I have a ragdoll script where it put a value inside the character. When you turn it on it ragdolls the players until you check the boolvalue off. I have problems with the ragdoll script flinging players. Also it takes extra seconds for the player to get up. Do you know how I can fix this to make player get up right after there ragdolled?

Gif of Player being Ragdolled:
https://gyazo.com/85026c9e1fa862a2405c9ad66798b179

2 Likes

When someone rag dolls, you can replace Motor6Ds to BallSocketConstraints.

1 Like

What is with all your variables being v(int)? This script is hard to understand.

1 Like

your script looks like it was ripped out of a game using synapse or somethin

2 Likes