So you got yourself some nice layered clothing drip, but dying makes your Robloxian shatter like glass into a million pieces. Not using R15 for your game? No problem! You can change it up with this system easily.
Introducing: Ragdoll Solution!
GET IT FREE HERE
Built on Layered Clothing
The initial idea of this project was to get a layered clothing to work on a ragdoll system to reduce the encounter of removing accessories on stock Roblox. The technology behind layered clothing is amazing, but its experience is omitted on player deaths or reset. This is here to solve that. I want to encourage users to enjoy layered clothing on their characters or games; and this means letting this project be free to use or modify on Roblox. If you created modified version youâre proud of, Iâd love to see them on this thread!
Layered clothing also adds some performance weight, so Iâve also created some means to save it, turning this into a ragdoll system with added features. I suggest using it with 30 players in mind, and 60 players with performance options turned on.
Customizable *[1.0.8]
Here is how flexible this system is. If you want to use something that's not regular R15, then read this.
- Limb Manager
HumanoidStarterSet Script
Every limbpart or group of limbparts can be given unique preloaded ballsocket values.
-
If your rig has wing limbparts, you can give it separate ballsocket values from other limbparts by putting your wingâs limbparts names on a (hopefully easily) named table, and returning the table name from inside limbManager().
-
limbManager() will then choose from the SOCKET_SETTINGS_R15 array, to assign all those partâs ballsocket settings.
-
If a limbpart is not found, limbManager will return nil and the code will not proceed to look for something not included and continue safely. This is not intended to create a catch-all solution if all limbparts are read, but to allow deviations on similar rigs (like an R15, but spawned with one arm).
See how I grouped the hands and feets of the R15 parts, and gave them all the same ballsocket values, above. It doesnât have to be linear or symmetrical by any means.
You can completely deviate from these R15 settings, and create a limbManager function for R6 rigs if you wish. However, if you load characters of multiple different rigs in your game, I recommend to create your own code to identify the characterâs rig and load them each individually per character. This code does not do that, and assumes you will be using the same rig for every loaded player character.
If you do plan to edit this, see Performance Options to see important information.
*[1.0.8]
- On Avatar Scaling
Inside Humanoid, the property AutomaticScalingEnabled shouldnât be updated after ragdoll deaths due to weird bodyscaling and rig behaviors with parts changing on death.
Characters whose bodyscale values arenât 1 on spawn and have changed will have problems. If you want characters of dynamic bodyscales, I recommend spawning them with all bodyscale values as 1, and then updating them right after they spawn. Make sure all changes are done and seen via serverside.
Characters of static bodyscales donât seem to have this problem, but be aware of your usecase.
NPC Ragdolls and Player Ragdolls
The differences and likenesses on player ragdolls and NPC ragdolls.
The two scripts that NPCs will use
If you want to use custom NPC rigs, then you may go with this in two directions. Have different HumanoidStarterSet scripts with different settings for each rig, or alternatively, treat them like players, and create different limbManagers and SOCKET_SETTING tables for each rig, keeping one HumanoidStarterSet script for all.
HumanoidStarterSet scripts, out of the box, are interchangable to R15 NPCs and players. Their ragdolls however, activate differently.
-
NPCs use a simple humanoid.Died to run various functions intended to make the system work. They are placed in their character model.
-
Players go through PlayersAdded and CharacterAdded, and a ServerEvent to activate their ragdoll on humanoid.Died. One script handles all this, and is placed in ServerScriptService.
Both ragdolls activate a set of preloaded velocity constraints to begin the collapse of the ragdoll on death. Note, that this is MANDATORY FOR PLAYERS. For some reason, serverside player humanoids do not recognize their newfound state of death until they are awoken through physical interaction (Yes I am serious with this raw unfiltered irony).
This is the point of the ServerEvent. It is to activate velocity constraints from a clientside signal without bothering players when not needing them.
Performance Options
See the included performance options and how you should handle a custom rig to them.
There are several performance options to stop ragdolls and humanoid from destroying your frames. Ignoring these will drop runtime heartbeat, and raise a sweaty gamerâs heartbeat instead. These canât solve everything, so do your best to make sure players do not all die at once in the same frame.
On testing with all performance features on, 25 characters dying at once have made only 2.4% script activity max at a dropped heartbeat down to 47. Characters dying on separate frames spread the weight, with me seeing 1.5% script activity with no frame hiccups. In context, I have pretty turtle-speed 32GB ram running at 2133hz and an olâ Intel 6th gen.
- Load Control
charactersDied is tracked to make sure that players donât ragdoll all at once. charactersDiedMax is the cap of players who died until the next character has to wait to ragdoll. The time to wait is hardcoded as (0.1 * charactersDied)
.
After dying if charactersDiedMax is full, dead characters will behave as PlatformStand instead of ragdolling. NPCs and players both add to charactersDied. The purpose of this is to reduce the amount of activated ragdolls for framerate reasons, and even give physics computation a break.
charactersDiedDecay is how long it takes for charactersDied to drop by 1 after a player dies. This is handled by diedCountDecay in ServerScriptService. The purpose of this is to relieve framerate drops incase many characters initiate indexes at once via code.
- Ragdoll Freezing
ragdollFreezeTime is how long until a ragdoll anchors itself to stop interacting with physics. The conditions to freeze ragdolls is if their UpperTorso hasnât moved a hardcoded 2 studs away from its last checked position. This repeats on ragdollFreezeTimeâs seconds. All limbparts are then frozen if so.
You can enable or disable this feature with ragdollFreezeEnable. There is no function to unfreeze ragdolls.
- Low Definition Ragdolls
There are low-definition ragdolls to ease on physics performance.
WARNING: This is set to FALSE right now due to unpredictable circumstances, but functions.
ragdollsExisted and ragdollsLdMax work hand-in-hand. If the server has
(ragdollsLdMax < ragdollsExisted)
then NPC and Player ragdolls will break less joints in their ragdoll script (Not HumanoidStarterSet script). This is because of certain selected and found joints being destroyed, and isnât done with any algorithm.
Here is the reason why I told you to read this part back there. This is not very advanced, and if custom rigs are being used, it should be written to accommodate new limbparts. It wonât crash, but failing to read any valid parts will mean no ragdolls.
There is another problem where ragdolls which disappear from workspace before removing a ragdollsExisted value, will leave it stuck. The script ragdollExistedReset in ServerScriptService is a quick solution to reduce the value by one until zero at a steady rate at 2 minute intervals.
You can choose to enable Ld ragdolls through checking true ragdollsLdEnable.
Collision Control
These ragdolls work with collision groups! While it can run without it, it may be better to set it.
This system actively changes CollisionGroupIds. Living characters spawn with a CollisionGroup named âPlayersâ. Ragdolls are given a CollisionGroup name of âBodyâ. The above image shows that ragdolls (Named Body) will interact with eachother, but not with player characters (Named Players). You will have to create and assign these values with strings in your own game through Studio.
HumanoidStarterSet Script
Excuse my cringe amount of assignments, but this brutal usage of dot operators to sprinkle noCollisionConstraints on certain limbs is really R15 specific. If its found that a rig has its own miniature earthquake, then disabling collisions on certain limbparts to others may solve it. My code already creates noCollisionConstraints with each part connected to the same joint already atop of this. This wonât be a problem if Body is unchecked to avoid colliding with itself in Collsion Groups.
Install Guide
GET IT FREE HERE
To install, enter edit mode in this place, and copy them into your game so the paths look exactly the same. You can have a game work with the stock settings with no change, but I still recommend having Collsion Groups set. NPC scripts are included in the place. Also included in the place, but not part of this system is a keybinded L to reset, and a Bloxy Cola tool.
Notes
- This system works under the implication that HumanoidRootPart is never unattached from characters.
- Players unequip tools and empty backpacks on death. This is to greatly reduce desync on clothes and players.
- There were regular occurances of desync on ragdolls with layered clothes. This was fixed through a hacky mean through updating the accessory.
- Layered clothing wonât work for R6 rigs.
Release Notes
1.0.8
- CustomPhysicalProperties changes set to be closer to regular vanilla values to prevent disruption of gameplay.
- Attempt hotfix for scaling issues with some package and custom characters on death. This is for both NPCs and Players.
1.1.0
- Stopped the playing of animations upon the death of humanoid on both NPCs and Players
- Changes of some stock settings. RagdollsLdEnable is false and ragdollsLdMax is now 3. Prior settings had them not as described.
1.1.2
- Updated leftover code, changing CanCollide from false to true upon ragdolling
- Changed Collision Groups to its newer naming system.
1.1.3
- Removed this one line that loops and changes Custom Physical Properties in HumanoidStarterSet. This may fix some unread physics issues.
- Ragdoll Solution [Ver number] is now called Ragdoll Solution Resource because of Roblox moderation.
Thanks!
If there is a lot of interest, Iâll update this to include some more wanted features. Crediting isnât necessary, but you can do so by including Ragdoll Solution and my username in a credits section.