Customizable Ragdoll Module 1.1 (Create your own custom ragdolls!)

Customizable Ragdoll Module Version 1.1

Get the Module here

This module will allow you to create your own custom ragdolls.

Video

(Multiple Ragdoll modes running at the same time!)

Features

  • R15 and R6 compatibility
  • Player and NPC support
  • Premade scripts (Button to Ragdoll, Ragdoll Death)
  • Customizable: You can create your own ragdoll settings
  • Multiple RagdollModes: You can rig each character with different ragdoll settings

Quick Start

You can place the Ragdoll Module where you’d like, but I recommend placing it in ServerScriptService. This module comes with a default RagdollMode that should work just fine for most users, and is optimized for both R15 and R6.

I have made two scripts (Button to Ragdoll, Ragdoll Death) that you can use to easily add this module into your experience. These are located in the PremadeScripts Folder in the module. See the README in this folder for installation instructions. See section “PremadeScripts Settings” for settings.

Module Information

Basic Usage

Load the module

local Ragdoll = require(ServerScriptService.Ragdoll)

Rig characters, you can do this by rigging each character individually

Ragdoll.RigCharacter(character, ragdollMode)
  • If ragdollMode is nil, then it will apply a default value (either the RagdollModes Folder’s DefaultMode attribute or “Default”)
  • If the character is already rigged, this function will automatically unrig the character before rigging it again with the new ragdollMode
  • It’s a good idea to run this as soon as possible instead of rigging, then immediately ragdolling. But if you can’t avoid it, it should still work fine.

OR you can rig every player and players that join after by using

Ragdoll.RigPlayers(ragdollMode)

Ragdoll/unragdoll the character

Ragdoll.EnableRagdoll(character, impactData)
Ragdoll.DisableRagdoll(character)
  • (impactData is explained in the Module Functions section)
Module Settings
  • DebugPrintMode
    • Gives information that may be helpful when debugging, especially for catching typos
  • SetNPCOwnershipToServer
    • Sets NPC’s NetworkOwnership to server when ragdolled, and returns it to SetNetworkOwnershipAuto when unragdolled
  • (RagdollModes Folder) DefaultMode
    • Set this to the name of a module in this folder that you want to be the default mode. If this is blank, “Default” will be used instead
PremadeScripts Settings

Each script has settings that you can change. These will either be an attribute (in the Property window) or as a module named “Configuration”. These settings are listed below:

PressButtonToRagdoll
  • (ButtonRagdollServer Script)

    • RagdollMode

      • Set this to the name of the RagdollMode you want to use (in RagdollModes
        folder), will use the default RagdollMode if empty
    • AutoRigPlayers

      • If enabled, automatically rigs every player and players who join later. If using multiple scripts that have this setting, make sure to only have it enabled on one script
    • ApplyMoveDirectionVelocity

      • If enabled, adds Humanoid’s MoveDirection to ragdoll’s velocity
  • (ButtonRagdollClient Configuration Module)

    • Cooldown
      • How many seconds until player can ragdoll again
    • CreateMobileButton
      • If true, will make a mobile button
    • KeyCode
      • Keyboard button to activate
    • ControllerCode
      • Controller button to activate
    • RemoteEvent
      • RemoteEvent to fire to toggle ragdoll state
RagdollDeath
  • RagdollMode

    • Set this to the name of the RagdollMode you want to use (in RagdollModes folder), will use the default RagdollMode if empty
  • AutoRigPlayers

    • If enabled, automatically rigs every player and players who join later. If using multiple scripts that have this setting, make sure to only have it enabled on one script
  • ApplyMoveDirectionVelocity

    • If enabled, adds Humanoid’s MoveDirection to ragdoll’s velocity
  • FixDoubleDeathSound

    • Fixes double death sound by removing the player’s HumanoidStateManager on death
  • CreateDummy

    • If enabled creates a separate character on death. this prevents it from being destroyed when the character respawns
    • If you enable this, make sure to place the DummyCamera LocalScript in StarterPlayerScripts (this script is located in the RagdollDeath Script)
  • DummyLifetime

    • If CreateDummy is enabled, after this amount of seconds, the dummy will be removed

Module Functions
Ragdoll.RigCharacter(character, ragdollMode)
  • Rigs character by setting up attachments and constraints using ragdollMode
  • Before rigging, this function will automatically unrig the character if it is already rigged
  • if ragdollMode is nil, it will default to the default RagdollMode folder setting or “Default”
Ragdoll.UnrigCharacter(character)
  • Removes constraints and new attachments created, and unragdolls the character
Ragdoll.EnableRagdoll(character, impactData)
  • Will ragdoll the character if it is rigged, and not already in a ragdolled state
  • impactData affects the velocity applied to the character (this can be nil for no added velocity)
impactData Usage
impactData = {
  Part = --Can be [Part in character] or [name of part in character]. If nil then this will default to HumanoidRootPart if available
  Hit = --[Vector3] Position on impactData.Part to apply impact. If nil then defaults to impactData.Part's position
  Direction = --[Vector3] Direction of impact
  Speed = --[number] Speed of impact (default = 350)
  Lifetime = --[number] Amount of time that the impact will last (default = 0.3)
  UseLinearVelocity = --[bool] If true, use a LinearVelocity Instance instead of VectorForce Instance (default = false)
}
Ragdoll.DisableRagdoll(character)
  • Will unragdoll the character if it is rigged, and in a ragdolled state
  • This function will be called automatically when UnrigCharacter() is called
Ragdoll.RigPlayers(ragdollMode)
  • Automatically rigs every player with the provided ragdollMode
  • If this function was already run, it will not run again
Character Attributes

These are the attributes applied to each character model rigged by this module:

  • Ragdolled = boolean
    • This is enabled when the character is in a ragdolled state
  • RagdollLoaded = boolean
    • This is enabled after character is done being rigged and is ready to be ragdolled
  • RagdollMode = string
    • This is the currently selected RagdollMode for the character (Note that this will not change if R6RagdollMode setting gets applied)

Creating a new RagdollMode

There are two ways to create a new mode:
1. Using folders in the explorer (this way is easier to do)
2. Using a module script (this way can be more difficult if you don’t have much scripting experience, but you have more control when creating new constraints)

Creating a new RagdollMode using a folder

Create a New Folder

In the RagdollModes folder, Duplicate the folder named “FolderExampleTemplate” or create a new folder

Add Constraints

Open the Constraints folder in the newly created RagdollMode folder. Add the constraints you want to this folder, and set the name of the constraint to the motor you want it to apply to (this name can be the exact name or a part of it, this means that if I set the name to “Shoulder” will apply to both shoulders). Constraints must have these properties to work properly: Enabled and either Attachment0 and Attachment1 OR Part0 and Part1 (BallSocketConstraints, Hinges, WeldConstraints, etc). Below are the names of the motors in each character for both R6 and R15.

If you want to add multiple constraints to one motor, create a folder and place the constraints in that folder, setting the name of the folder to the motor you want it to apply to(constraint names inside this folder do not matter).

Any motor that is not listed will use the folder/constraint named “Default”. If you want a motor to not be disabled, and have no constraints attached to it when ragdolled, create a StringValue, and set the name to the motor, and the value to “None”.

Extra Settings and Functions

In the Settings folder, there are two settings: R6RagdollMode and BreakJointsOnDeath, both these settings can be deleted if you aren’t using them.

  • R6Ragdollmode
    • If the character’s rig is R6, this RagdollMode will be loaded instead
    • If this is set to nil, then the current RagdollMode will be used for both R6 and R15
    • This value can be a ModuleScript or Folder
  • BreakJointsOnDeath
    • Disables the character falling apart on death (defaults to false)

There are also four functions (in RagdollStateFunctions ModuleScript) that fire when the character is ragdolled/unragdolled and two that fire when the character is rigged/unrigged. See the ExampleTemplate for instructions on how to use these. If you don’t need them, they can be deleted.

If you don’t plan on using these settings or functions, you can delete them.

Wrapping Up

Your RagdollMode should now be ready to use! Don’t forget to test it and if you are using my PremadeScripts, then change the RagdollMode setting to your new RagdollMode.

Creating a new RagdollMode using a module script

(Check out the ExampleTemplate Module in the RagdollModes Folder for detailed explanations on what everything does.)
Create a new RagdollMode ModuleScript

Open the RagdollModes folder. Every RagdollMode needs to be placed here to work. You can copy and paste the Default or ExampleTemplate ModuleScript to use as a base if you want. ExampleTemplate lists and explains every setting/function in detail.

Create a ConstraintTypes (table or a ModuleScript in ConstraintTypes Folder)

If you use a ModuleScript, I have created a module to load multiple ConstraintTypes modules,
you can use this module by doing

local LoadConstraintTypes = require(Ragdoll.LoadConstraintTypes)
local ConstraintTypes = LoadConstraintTypes("Example", "Example2")

You can load as many as you want, just note that each module will overwrite every module to the left of it (this only applies to matching entries). For example: “ConstraintType1” in “Example2” will overwrite “ConstraintType1” in “Example”.

This is the format for each ConstraintType in the ConstraintTypes table:

ConstraintTypes.ConstraintName = function(character, motor, r6, attach0, attach1) --You can omit the parameters if you aren't using them
  local newConstraint = Instance.new([ClassName]) --This instance needs an Enabled property and either a Attachment0/1 or Part0/1 property to work
  --modify newConstraint
  return newConstraint
end
  • Parameters:
    • character
      • The characterModel being rigged
    • motor
      • The motor that this ConstraintType is being applied to
    • r6
      • This is true if the character is an R6 rig
    • attach0, attach1
      • These are the attachments used by the ConstraintType. if the character’s rig is R6, new attachments will be made when rigging the character, but if the rig is R15, it will use the attachments already created by Roblox’s CoreScripts, so be careful when modifying these

(IMPORTANT) Make sure to set RagdollMode.ConstraintTypes to the ConstraintTypes table

Assign Motor6Ds to ConstraintTypes

Once you are done creating your ConstraintTypes table, now you can pick which ConstraintType is applied to each motor in the RagdollMode.Motors table.

Motors table format:

ragdollMode.Motors = {
  MotorName = "ConstraintType",
}

MotorName is the character’s motor that “ConstraintType” will be applied to
The MotorName can either be the exact Motor6D name or a part of it. For example MotorName “RightShoulder” will only apply to the “RightShoulder” Motor6D, while MotorName “Shoulder” will apply to both Motor6Ds “LeftShoulder” and “RightShoulder”.

Motor Names and Locations

A Motors table that affects every Motor6D would look like this: (This works with both R6 and R15)

ragdollMode.Motors = {
	Root = "Weld",

	Neck = "NeckHinge",
	Waist = "Weld",

	Shoulder = "Default",
	Elbow = "ElbowSocket",
	Wrist = "WristAnkleSocket",

	Hip = "Default",
	Knee = "KneeSocket",
	Ankle = "WristAnkleSocket",
}

“ConstraintType” can also be set to a table to apply multiple ConstraintTypes to one MotorName. This can be useful if you want to add trails to your ragdoll.

 MotorName = {"ConstraintType1", "ConstraintType2"}

If a MotorName is set to nil it will use the RagdollMode.DefaultConstraintType value (below the Motors table). If set to “None” that motor will be skipped and will not be disabled when the character ragdolls.
If RagdollMode.DefaultConstraintType is not set, it will default to “Default”

Extra Settings and Functions

There are two settings: R6RagdollMode and BreakJointsOnDeath, both these settings can be deleted if you aren’t using them.

  • R6Ragdollmode
    • If the character’s rig is R6, this RagdollMode will be loaded instead
    • If this is set to nil, then the current RagdollMode will be used for both R6 and R15
    • This value can be a Folder, ModuleScript object, a loaded ModuleScript, or a string (must match a ModuleScript in RagdollModes Folder)
  • BreakJointsOnDeath
    • Disables the character falling apart on death (defaults to false)

There are also four functions that fire when the character is ragdolled/unragdolled and two that fire when the character is rigged/unrigged. See the ExampleTemplate for instructions on how to use these. If you don’t need them, they can be deleted.

Wrapping Up

Your RagdollMode should now be ready to use! Don’t forget to test it and if you are using my PremadeScripts, then change the RagdollMode setting to your new RagdollMode


How to update

  1. (optional) Duplicate the Ragdoll module you are currently using, and move it somewhere else, so you can go back to this version in case something goes wrong
  2. Install the new version from the toolbox
  3. In the new version, delete folders “RagdollModes”, and “ConstraintTypes”, and replace them with the same folders in the version you are currently using
  4. If you are using any PremadeScripts, copy settings(attributes/configuration modules) from the old version to the new version, and then replace each script
  5. Replace the old Ragdoll module with the updated version

I hope you find this module useful. If you have any suggestions or bug reports, please share.
Also feel free to share your own ragdoll modes that you make, I would love to see what you create!

10 Likes

Looks great- I’m currently working on a project so I’ll consider using this for the NPCs deaths to save me some time

1 Like

Thank you! If you already installed the module, you might want to update it. Sometimes the network ownership of NPCs get changed to nearby players, which breaks the ragdoll. I’ve added an optional setting in the newest version to fix this, as an attribute named SetNPCOwnershipToServer

1 Like

Update: Version 1.1

I have added a new, easier way to create ragdoll modes, which involves creating objects in the Explorer instead of using module scripts.

Creating a new RagdollMode with the new method

Create a New Folder

In the RagdollModes folder, Duplicate the folder named “FolderExampleTemplate” or create a new folder

Add Constraints

Open the Constraints folder in the newly created RagdollMode folder. Add the constraints you want to this folder, and set the name of the constraint to the motor you want it to apply to (this name can be the exact name or a part of it, this means that if I set the name to “Shoulder” will apply to both shoulders). Constraints must have these properties to work properly: Enabled and either Attachment0 and Attachment1 OR Part0 and Part1 (BallSocketConstraints, Hinges, WeldConstraints, etc). Below are the names of the motors in each character for both R6 and R15.

If you want to add multiple constraints to one motor, create a folder and place the constraints in that folder, setting the name of the folder to the motor you want it to apply to(constraint names inside this folder do not matter).

Any motor that is not listed will use the folder/constraint named “Default”. If you want a motor to not be disabled, and have no constraints attached to it when ragdolled, create a StringValue, and set the name to the motor, and the value to “None”.

Extra Settings and Functions

In the Settings folder, there are two settings: R6RagdollMode and BreakJointsOnDeath, both these settings can be deleted if you aren’t using them.

  • R6Ragdollmode
    • If the character’s rig is R6, this RagdollMode will be loaded instead
    • If this is set to nil, then the current RagdollMode will be used for both R6 and R15
    • This value can be a ModuleScript or Folder
  • BreakJointsOnDeath
    • Disables the character falling apart on death (defaults to false)

There are also four functions (in RagdollStateFunctions ModuleScript) that fire when the character is ragdolled/unragdolled and two that fire when the character is rigged/unrigged. See the ExampleTemplate for instructions on how to use these. If you don’t need them, they can be deleted.

If you don’t plan on using these settings or functions, you can delete them.

Wrapping Up

Your RagdollMode should now be ready to use! Don’t forget to test it and if you are using my PremadeScripts, then change the RagdollMode setting to your new RagdollMode.

How to update

  1. (optional) Duplicate the Ragdoll module you are currently using, and move it somewhere else, so you can go back to this version in case something goes wrong
  2. Install the new version from the toolbox
  3. In the new version, delete folders “RagdollModes”, and “ConstraintTypes”, and replace them with the same folders in the version you are currently using
  4. If you are using any PremadeScripts, copy settings(attributes/configuration modules) from the old version to the new version, and then replace each script
  5. Replace the old Ragdoll module with the updated version