Yea you need the character of the npc and just do
module:RigPlayer(NPC)
Yea you need the character of the npc and just do
module:RigPlayer(NPC)
Oh thanks. I overcomplicated things a little. I’ll let you know if it works or not
Hey your module works very well with player but for some reason it have this strange behavior with npcs:
https://gyazo.com/e739abd87ed0c8edafb97e8ececa8d9d
I got it working fine with npcs for some time but it randomly broke and it doesnt work fine anymore, maybe I did something wrong?
found the issue: the problem was that ragdoll connections was apparently being cleared
How would you do that exactly? Like for a npc or a player
Nice, but it doesn’t seem to work for me @kalabgs. I’m rigging each player’s characters upon join, and I know that’s not the problem because the RiggedUser attribute is appearing on the humanoid. Whenever a player dies, their body just falls flat and their head falls off and goes through the baseplate.
local function PlayerAdded(Player: Player)
Player.CharacterAdded:Connect(function(character)
RagdollModule:RigPlayer(character)
end)
end
Players.PlayerAdded:Connect(PlayerAdded)
for _, v in ipairs(Players:GetPlayers()) do
task.spawn(function()
PlayerAdded(v)
end)
end
Getting some weird issues. I rig when a character is added, although for certain characters, it says v.Part0 of the weld is nil. When I go into the explorer and look at the weld, it’s not nil.
Edit: I fixed it by waiting to rig the character until the first time I ragdoll them, although this does not seem efficient.
Ok, I need to ask
Why are you connecting the events to functions inside the for loop?
Not sure if he changed the state change value but it works now after changing the HumanoidStateType to Enum.HumanoidStateType.Physics instead of .Ragdoll
Community Update Version
by me
I Decided to change some stuff back-end meaning visually it all should be the same.
What I changed:
Update! (2023-05-28):
Usage is pretty much the same, except that you will now have to change humanoid state into gettingup for the character to stand back up to normal.
Usage is the same except now you handle connection functions outside the module and tell the module to perform its task from the script instead.
local plr = game:GetService("Players").LocalPlayer
local char = script.Parent
local input = game:GetService("UserInputService")
local db = false
input.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.P then
if db == false then
db = true
--Ragdoll character!
plr.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
else
db = false
--Recover character from ragdoll!
plr.Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end
end)
(also remember that in this module you have to use physics state to trigger ragdoll)
My update on this module:
local mod = {}
function mod:RigPlayer(Character : Model)
local hum : Humanoid? = Character:WaitForChild("Humanoid")
local hrp : BasePart? = Character:WaitForChild("HumanoidRootPart")
assert(hum,Character.Name.." isnt a humanoid")
hum.BreakJointsOnDeath = false
local WeldConstranint = Instance.new("WeldConstraint",hrp)
for _,v in pairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
local BallSocket = Instance.new("BallSocketConstraint",v.Part0)
BallSocket.Name = "BC"
if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
v.Part1.CanCollide = false
v.Part0.CanCollide = false
end
local att1 = Instance.new("Attachment",v.Part0) att1.Name = "AttRag"
local att2 = Instance.new("Attachment",v.Part1) att1.Name = "AttRag"
att2.Position = v.C1.Position
att1.WorldPosition= att2.WorldPosition
BallSocket.LimitsEnabled = true
BallSocket.TwistLimitsEnabled = true
BallSocket.Attachment0 = att1
BallSocket.Attachment1 = att2
if v.Part0 == Character.PrimaryPart and v.Part1 ~= Character.PrimaryPart then
WeldConstranint.Part0 = Character.PrimaryPart
WeldConstranint.Part1 = v.Part1
WeldConstranint.Enabled = false
end
end
end
end
function mod:Ragdoll(Character : Model)
local humanoid : Humanoid = Character:WaitForChild("Humanoid")
for _, v in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
v.Part1.CanCollide = true
v.Enabled = false
else
Character.PrimaryPart:FindFirstChild("WeldConstraint").Enabled = true
Character.PrimaryPart.CanCollide = false
end
end
end
end
function mod:Recover(Character : Model)
local humanoid : Humanoid = Character:WaitForChild("Humanoid")
for _, v in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
v.Part1.CanCollide = false
v.Enabled = true
else
Character.PrimaryPart:FindFirstChild("WeldConstraint").Enabled = false
Character.PrimaryPart.CanCollide = true
end
end
end
end
function mod:Deathphysics(Character : Model)
for _, v in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
v.Part1.CanCollide = true
v:Destroy()
else
Character.PrimaryPart:FindFirstChild("WeldConstraint").Enabled = true
Character.PrimaryPart.CanCollide = false
end
end
end
end
return mod
The original can be found at the top of the page! This is not the original, this is a community updated version.
Can you give a ServerScript example for the community updated version
Hi! I was once wandering around devforum when I found this post, I decided it was interesting so I tried it (both the original and community version) and I found some things that could probably be improved on. I’ve already made and tested a few different versions, but this one (link attached below) it the latest one.
Reason for me to make my own version
Like the original and community version, it ragdolls every rig type. Some issues I found with these 2 scripts were, for example, shiftlock moves the character while ragdoll, camera shaking a lot during ragdoll, not compatible with npcs, etc. I found this forum quite useful so I fixed all of those!
For basic setup, you would want to put it in somewhere you can require it from, I recommend ServerStorage. To have a ragdollable character, you have to first setup the rigs.
local ServerStorage = game:GetService("ServerStorage")
local Module = require(ServerStorage.Ragdoll)
Module:RigCharacter(character) -- NPC characters works too!
The character can be taken from CharacterAppearanceLoaded, or just script.Parent
if it’s a script in an NPC.
*Note: Write the code in server scripts!
local ServerStorage = game:GetService("ServerStorage")
local Module = require(ServerStorage.Ragdoll)
local knockback = {}
knockback.Direction = Part.CFrame.LookVector
knockback.Strength = 60
Module:Ragdoll(character, knockback, time)
Again, the character can be a player or an NPC. The character must be rigged beforehand, or nothing would happen. I’ll explain ‘knockback’ in detail, ‘time’ is just how many seconds to wait until the character unragdolls. You can leave it blank if you don’t want it to unragdoll.
For knockback, it has 2 properties, Direction and Strength. Direction is simple, you can either have a set direction with Vector3.new()
or you can use CFrame.LookVector
, for example, launching an enemy at the direction your character is facing. Strength is self-explanatory, it’s basically how large the knockback will be, the higher it is, the further the character gets knocked back.
Like ‘time’, you can leave it blank or nil
if you don’t want the knockback, and it will simply just ragdoll without any knockback.
(It was made so I could apply knockback easier, not really necessary though)
One thing you may also want to take note is when a r6 ragdoll lands on a thin platform of > 1~2 studs, it sometimes may glitch through the platform since it has a custom collider and it’s smaller than the default body part.
*Write the code in server scripts!
Links
Module: https://create.roblox.com/store/asset/18723516623/Ragdoll-Module
Testing Experience: Ragdoll Test - Roblox
(Edit: To clarify, I actually rewrote 70~80% of the code, but some main components are still the same hence I posted the remake here instead of a new post)
Last updated at 7/30/2024 (changes: slightly less lag + smooth unragdoll system)
Scroll up for the original version, this is only a remake of this module!
Bro… I love you and the original poster, this has to be the smoothest Ragdoll system I have ever seen in Roblox. I tested many Ragdoll systems in here and usually they lag as soon as they switch from normal to ragdoll but this… its unnoticeable its insane! Really appreciate it from you two <3
(Sorry for reviving this topic but I had to say it for this masterpiece should not be unnoticed)
Excellent, Nice work!
My module I must say is quite outdated and my skills since then have improved quite a lot.
From now on for any newcomers that visit this forum I suggest using this module here, since mine is very rusty and I have no intention of updating it (anytime soon at least).
Hey, so apparently I have this problem where everytime players are ragdolled, they clip through the map. This isn’t the case for NPCs though.
i’m currently not on my computer and cant get on for the day so i cant test, but the problem might be with the custom colliders, which i’ve made them for r6 avatars only for smoother ragdoll. you can probably disable it (might be less smooth)
i’ll try to help more tmr when i get on
pretty sure either the default body parts’ or the custom colliders’ collisiongroup will changed when ragdoll toggles to avoid it interfering with each other, might want to look into that and see if it might fix something
No worries, I already solved the issue. Cheers
Smoothest ragdoll module ever. Anyways, I’ve made changes for the module as some of the module’s components are outdated: Al's Ragdoll Module
Is it still unnoticable for you, if you are still using this module? I just set up mine and the lag you mentioned is VERY noticable from server