Currently have a ragdoll system that works fine for players, but when I use it on the server for NPC’s, it seems to break half the time.
As you can see here, whenever the NPC ragdolls, it hovers in place for some reason, but when I activate the ragdoll on the player (which is using the exact same code) it works as intended.
However, sometimes it actually does work, and I was able to snag a quick gif of it.
I suspect it as something to do with the BodyVelocity I add to the character’s HumanoidRootPart just to push the it back a bit, however it only applies a force for 0.125 seconds so I don’t understand what the issue is. Perhaps some other HumanoidState is being triggered during that small window? No idea.
Entity.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false) Entity.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false) Entity.Humanoid:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics, false) Entity.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll) Entity.Humanoid.WalkSpeed = 0 Entity.Humanoid.JumpHeight = 0 for _, Child in ipairs(Entity.Torso:GetChildren()) do if Child:IsA("Motor6D") then local BallSocket = Instance.new("BallSocketConstraint") BallSocket.Name = Child.Name local Attachment0 = Instance.new("Attachment") local Attachment1 = Instance.new("Attachment") Attachment0.Parent = Child.Part0 Attachment1.Parent = Child.Part1 BallSocket.Attachment0 = Attachment0 BallSocket.Attachment1 = Attachment1 BallSocket.Parent = Child.Parent Attachment0.CFrame = Child.C0 Attachment1.CFrame = Child.C1 Debris:AddItem(Attachment0, 3) Debris:AddItem(Attachment1, 3) BallSocket.LimitsEnabled = true BallSocket.TwistLimitsEnabled = true Child.Enabled = false end end local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.MaxForce = Vector3.new(20000, 20000, 20000) BodyVelocity.Velocity = Entity.HumanoidRootPart.CFrame.LookVector * -30 BodyVelocity.Parent = Entity.HumanoidRootPart Debris:AddItem(BodyVelocity, 0.125)
I haven’t included the code that resets the Character back to it’s previous states and all that, but I assure you that it’s there and working. If you do need it for further debugging, I’ll edit the code above and add it.