What's the best way to make an R6 ragdoll that can be toggled?

I created ragdolls that can be toggled by enabling a bool inside the character, setting it to true will ragdoll the character and setting it to false will un-ragdollify them. The problem is, the ragdolls sometimes explode and they lose all their limbs except the Torso and Head.

Can someone tell me why they explode and if there is any way to counteract this?

2 Likes

Can you provide code for further help?

1 Like

I can’t help you without the script. Can you provide us the script please?

1 Like

Apparently, you did not provide a script that could give us an accurate diagnosis of the problem. Could you please provide the code that is relevant to the BoolValue?

The script is RagdollPlayer, type the in this format:

YOUR CODE HERE

pic

lol ignore the red lining

1 Like

Sorry, here’s the script RagdollPlr.lua (3.6 KB)

1 Like

I don’t want to download a file from people I don’t know. Can’t you just copy the script and write it like this:
Your Script

Might as well drop the script here, for people who don’t want to download it.

game.Players.PlayerAdded:Connect(function(plyr)
	plyr.CharacterAdded:Connect(function(char) 
		local value = Instance.new("BoolValue", char)
		value.Name = "ragdoll" 
		value = false
		
		char.ragdoll.Changed:Connect(function(newVal)
			if newVal == true then
				wait()
				ragdollChar(char)
			elseif newVal == false then
				wait()
				resetChar(char)
			end
		end)
	end)
end)

joints = {} welds = {} fakeLimbs = {}
ragdolling = false

function resetChar(char)
	if ragdolling then
		ragdolling = false
		wait()
		for _, this in pairs(joints) do 
			this.Parent = char.Torso -- Add the joints back
		end
		for _, this in pairs(welds) do 
			this:Destroy() -- destroy old welds
		end
		for _, this in pairs(fakeLimbs) do 
			this:Destroy() -- destroy temp parts
		end
		char.Humanoid.PlatformStand = false
	end
end

function ragdollChar(char)
	if not ragdolling then
		
		ragdolling = true; char.Humanoid.PlatformStand = true
		
		local leftArm = char["Left Arm"]
		local rightArm = char["Right Arm"]
		local leftLeg = char["Left Leg"]
		local rightLeg = char["Right Leg"]
		local head = char.Head
		local torso = char.Torso
		local function cloneJoints(character)
			for _,this in ipairs(character.Torso:GetChildren()) do
				if this:isA("Motor6D") and this.Name ~= "Neck" then
					joints[this.Name] = this:Clone()
				end
			end
		end	
		local function createGlue(part0, part1, name)
			local glue = Instance.new("Glue", torso)
			glue.Part0 = part0;glue.Part1 = part1;glue.Name = name
			welds[#welds+1] = glue
			return glue
		end	
		local function createLimb(parent, position, size)
			local limb = Instance.new("Part", parent)
			limb.Position = position;limb.Size = size;limb.Transparency = 1
			fakeLimbs[#fakeLimbs+1] = limb
			return limb
		end
		local function createWeld(parent, p0, p1)
			local weld = Instance.new("Weld", parent)
			weld.Part0 = p0;weld.Part1 = p1;
			weld.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
			welds[#welds+1] = weld
			return weld
		end
		
		cloneJoints(char)
		-- LEFT LEG --
		char.Torso["Left Hip"]:Destroy()
		local glue = createGlue(torso, leftLeg, "Left leg")
		glue.C0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
		glue.C1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
		local fakeLeftLeg = createLimb(leftLeg, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))
		createWeld(fakeLeftLeg, leftLeg, fakeLeftLeg)
		-- RIGHT LEG --
		char.Torso["Right Hip"]:destroy()
		local glue = createGlue(torso, rightLeg, "Right leg")
		glue.C0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
		glue.C1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
		local fakeRightLeg = createLimb(rightLeg, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))
		createWeld(fakeRightLeg, rightLeg, fakeRightLeg)	
		-- RIGHT ARM --
		char.Torso["Right Shoulder"]:destroy()
		local glue = createGlue(torso, rightArm, "Right shoulder")
		glue.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
		glue.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)	
		local fakeRightArm = createLimb(rightArm, Vector3.new(0,999,0), Vector3.new(1.8,1,1))
		createWeld(fakeRightArm, rightArm, fakeRightArm)
		-- LEFT ARM --
		char.Torso["Left Shoulder"]:destroy()
		local glue4 = createGlue(torso, leftArm, "Left shoulder")
		glue4.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
		glue4.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)		
		local fakeLeftArm = createLimb(leftArm, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))	
		createWeld(fakeLeftArm, leftArm, fakeLeftArm)
	end
end

Looks like you deleted the Motor6D, which then caused the character’s limbs to be destroyed.

10 Likes

Instead of destroying the Motor6Ds, getting rid of the Part0 will do the trick, as you’re able to put it back on because you can store it as a variable.

1 Like

I’ll try that, thanks a lot for the help