[OUTDATED] Ragdoll Module For All Rig's (R15 / R6 / Custom) & Temporary Ragdoll's

Kiy4ku’s Ragdoll Module


Features

Temporary Ragdoll                         "You can create temporary ragdols without using tasks or coroutines."
Prevent Overwriting in Temporary Ragdolls "If something is ragdolled for 10 seconds and is ragdolled again for 5 seconds before the 10 seconds are up, the remaining time from the initial 10 seconds will continue if it is more than 5; but, if it is less than 5, the remaining time will be replaced with 5 seconds."
Custom Constraints                        "You don't have to ragdoll something with just BallSocketConstraints, when using :rig() you can edit the constraintsInfo table as you like, if you leave it empty it will be automatically rigged with BallSocketConstraint."
Easy To Use                               "Simple and elegant."
Lightweight                               "It doesn't include while and repeat loops, and without using initTimeStamps(), it won't be used in RunService. Rigged entities can be easily ragdolled using attributes or modules."


Documentation

METHODS

rig(instance: Model, constraintsInfo: ConstraintsInfo?): RBXScriptConnection?
"To be able to ragdoll something, it identifies all joints and creates constraints on the joints according to constraintsInfo or automatically creates a BallSocketConstraint on the joints. Returns the AttributeChanged Connection or nil."
ragdoll(ragdoll: boolean, instance: Model, duration: number?)
"If an instance has RagdollConstraints Folder, it disables the Motor6Ds in the instance and enables the Constraints."
initTimeStamps()
"In _G, it creates a connection and a table. In the table, it lists the objects being ragdolled and specifies the duration for which they will remain in the ragdolled state. If you don't do this, even if you input a duration to 'ragdoll()', it will not work."

Information

  • If you ragdoll something and the ragdolled thing has a humanoid, i.e. is a character, don’t forget to do Humanoid:ChangeState(Enum.HumanoidStateType.Physics).

  • When a player dies, you can set player.Character = nil from the server, then delete the character. On the client side, you can clone the character at the moment it’s being deleted, enabling you to ragdoll the character without any problem. (To prevent freezing.)

  • The module detects the last word of the joints and accordingly, creates folders in RagdollConstraints Folder for example: RightShoulder → Shoulder (The joint names in the ConstraintsInfo table should also be the last word of the joint.)


Examples

constraintsInfo Example
Neck = {
	NoCollisionConstraint = {},
	BallSocketConstraint = {
		LimitsEnabled = true,
		TwistLimitsEnabled = true,
		TwistLowerAngle = -40,
		TwistUpperAngle = 40
	}
},

Shoulder = {
	NoCollisionConstraint = {},
	BallSocketConstraint = {
		UpperAngle = 20,
		LimitsEnabled = true,
		TwistLimitsEnabled = true,
		TwistLowerAngle = -40,
		TwistUpperAngle = 20
	}
},

Waist = {
	NoCollisionConstraint = {},
	BallSocketConstraint = {
		LimitsEnabled = true,
		TwistLimitsEnabled = true,
		TwistLowerAngle = -40,
		TwistUpperAngle = 40
	}
},

Elbow = {
	WeldConstraint = {}
},

Wrist = {
	NoCollisionConstraint = {},
	BallSocketConstraint = {
		UpperAngle = 15,
		LimitsEnabled = true,
		TwistLimitsEnabled = true,
		TwistLowerAngle = -15,
		TwistUpperAngle = 15
	}
}
Simple Ragdoll Example
local ragdoll = require(modules.Ragdoll)
ragdoll:initTimeStamps() -- It's necessary for temporary ragdoll's

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAppearanceLoaded:Connect(function(character)
        ragdoll:rig(character) -- ragdoll:rig(character, constraintsInfo)
	    ragdoll:ragdoll(true, character, 5) -- or ragdoll:ragdoll(true, character) or character:SetAttribute("Ragdolled", true)
    end)
end)
Server - Client Example

Server

local ragdoll = require(game:GetService("ReplicatedStorage").Ragdoll)

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
        repeat task.wait() until player:HasAppearanceLoaded()

		ragdoll:rig(character) -- ragdoll:rig(character, constraintsInfo)
		
		local humanoid = character:FindFirstChildWhichIsA("Humanoid")
		if not humanoid then return end
		
		humanoid.Died:Connect(function()
			player.Character = nil
			character:Destroy()
		end)
	end)
end)

Client

local players = game:GetService("Players")
local ragdoll = require(game:GetService("ReplicatedStorage").Ragdoll)

local function playerAdded(player: Player)
	player.CharacterRemoving:Connect(function(character)
		character.Archivable = true
		local clonedCharacter = character:Clone()
		local humanoid = clonedCharacter:FindFirstChildWhichIsA("Humanoid")

		if character.Name == players.LocalPlayer.Name then
			players.LocalPlayer.Character = nil
			
			local camera = workspace.CurrentCamera
			if humanoid and camera then
				camera.CameraSubject = humanoid
			end
		end

		character:Destroy()

		ragdoll:ragdoll(true, clonedCharacter)
		clonedCharacter.Parent = workspace

		if humanoid then
			humanoid:ChangeState(Enum.HumanoidStateType.Physics)
		end

		task.delay(players.RespawnTime, function()
			if clonedCharacter then
				clonedCharacter:Destroy()
			end
		end)
	end)
	
	player.CharacterAdded:Connect(function(character)
		repeat task.wait() until player:HasAppearanceLoaded()

		character:GetAttributeChangedSignal("Ragdolled"):Connect(function()
			local humanoid = character:FindFirstChildWhichIsA("Humanoid")
			if humanoid then
				if character:GetAttribute("Ragdolled") then
					humanoid:ChangeState(Enum.HumanoidStateType.Physics)
				else
					humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
				end
			end
		end)
	end)
end

playerAdded(players.LocalPlayer)
players.PlayerAdded:Connect(playerAdded)

NEW VERSION

49 Likes
player.CharacterAdded:Connect(function(character)
		repeat task.wait() until player:HasAppearanceLoaded()

There’s actually a built in event for this, player.CharacterAppearanceLoaded. Excellent resource though.

2 Likes

“player.CharacterAppearanceLoaded” There are times when this method doesn’t work, so I did this as a precaution.

That’s a good module! Great job.

2 Likes

Hello, I love the ragdoll and I would like to use it but I have a problem.
image
On my game when ragdolled the characters accessories sizes get weird and the legs fall off. Any fix?

1 Like

I fixed the mesh sizes but now its just my legs falling off.

1 Like

I tried with the same character, but I did not encounter such an error. Can you send the code?

In CharacterAdded

task.wait(5)
	
	Ragdoll:rig(Character, ConstraintsInfo)
	while task.wait(3) do
		Ragdoll:ragdoll(true, Character, 1.5)
	end

Above character added

local ConstraintsInfo = {
	Neck = {
		NoCollisionConstraint = {},
		BallSocketConstraint = {
			LimitsEnabled = true,
			TwistLimitsEnabled = true,
			TwistLowerAngle = -40,
			TwistUpperAngle = 40
		}
	},

	Shoulder = {
		NoCollisionConstraint = {},
		BallSocketConstraint = {
			UpperAngle = 20,
			LimitsEnabled = true,
			TwistLimitsEnabled = true,
			TwistLowerAngle = -40,
			TwistUpperAngle = 20
		}
	},

	Waist = {
		NoCollisionConstraint = {},
		BallSocketConstraint = {
			LimitsEnabled = true,
			TwistLimitsEnabled = true,
			TwistLowerAngle = -40,
			TwistUpperAngle = 40
		}
	},

	Elbow = {
		WeldConstraint = {}
	},

	Wrist = {
		NoCollisionConstraint = {},
		BallSocketConstraint = {
			UpperAngle = 15,
			LimitsEnabled = true,
			TwistLimitsEnabled = true,
			TwistLowerAngle = -15,
			TwistUpperAngle = 15
		}
	}
}

Ragdoll:initTimeStamps()

And heres the client code

local function playerAdded(player: Player)
	player.CharacterRemoving:Connect(function(character)
		character.Archivable = true
		local clonedCharacter = character:Clone()
		local humanoid = clonedCharacter:FindFirstChildWhichIsA("Humanoid")

		if character.Name == Players.LocalPlayer.Name then
			Players.LocalPlayer.Character = nil

			local camera = workspace.CurrentCamera
			if humanoid and camera then
				camera.CameraSubject = humanoid
			end
		end

		character:Destroy()

		Ragdoll:ragdoll(true, clonedCharacter)
		clonedCharacter.Parent = workspace

		if humanoid then
			humanoid:ChangeState(Enum.HumanoidStateType.Physics)
		end

		task.delay(Players.RespawnTime, function()
			if clonedCharacter then
				clonedCharacter:Destroy()
			end
		end)
	end)

	player.CharacterAdded:Connect(function(character)
		repeat task.wait() until player:HasAppearanceLoaded()

		character:GetAttributeChangedSignal("Ragdolled"):Connect(function()
			local humanoid = character:FindFirstChildWhichIsA("Humanoid")
			if humanoid then
				if character:GetAttribute("Ragdolled") then
					humanoid:ChangeState(Enum.HumanoidStateType.Physics)
				else
					humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
				end
			end
		end)
	end)
end

playerAdded(Players.LocalPlayer)
Players.PlayerAdded:Connect(playerAdded)

I modified the Ragdoll module a bit but nothing that would break the feet.

Also, when I reset, breaks the meshes.

1 Like

Of course the joints of your feet will break because you didn’t write anything about your feet in constraints. Try rig without constraintinfo

1 Like

Ah, alright. I thought the constraint info was needed.

1 Like

It works pretty well! though im pretty new to studio and dont know how exactly everything works. I managed to setup the Server and Client scripts but i was wondering, how or where do i setup the “constraintsInfo”?

constraintInfo is optional parameter but if you want to write your own constraintInfo the format is as follows;

local constraintInfo = {
   Neck = { -- An rig limb name of your rig
      BallSocketConstraint =  { -- Constraint name
                        -- Properties of constraint
			UpperAngle = 15,
			LimitsEnabled = true,
			TwistLimitsEnabled = true,
			TwistLowerAngle = -15,
			TwistUpperAngle = 15
	}

    --...
   }
}

Just it, i hope it’s help you

1 Like

For some reason I’m having issues with ragdolling r6 characters

1 Like

I’ll fix it on new version thanks for feedback

1 Like

If you need more info about this let me know :+1:

2 Likes

Would you mind providing a project file for this?

1 Like

Why does my zombie’s ragdoll keep bouncing up and down after it ragdolls?

Ragdoll:rig(model)
Ragdoll:initTimeStamps()
local function onDied()
	Ragdoll:ragdoll(true, model, 1.5)
end
local Ragdoll = require(game.ReplicatedStorage:WaitForChild("Utility"):WaitForChild("Ragdoll"))
Ragdoll:initTimeStamps()
Ragdoll:rig(script.Parent.Parent) -- ragdoll:rig(character, constraintsInfo)


task.delay(10, function()
	Ragdoll:ragdoll(true, script.Parent.Parent, 10)
end)

Excuse me, why is my character floating in the air? How can I adjust the settings to make the character fall down like in your video?

Any updates on the R6 character fixes?