I’m using this server-sided ragdoll and it works pretty smoothly thanks to this this post.
To make the ragdoll smooth, I disabled the RootJoint of the HRP and enabled it after ragdoll.
This is how I did it:
if not ragdoll then
-- i also have to add this to prevent the player from falling into the void
local weldConstraint = Instance.new("WeldConstraint")
weldConstraint.Part0 = characterSubject.PrimaryPart
weldConstraint.Part1 = characterSubject.Torso
weldConstraint.Name = "RagdollWeld"
weldConstraint.Parent = characterSubject.PrimaryPart
characterSubject.PrimaryPart.RootJoint.Enabled = false
else
characterSubject.PrimaryPart.RootJoint.Enabled = true
if characterSubject.PrimaryPart:FindFirstChild("RagdollWeld") then
characterSubject.PrimaryPart.RagdollWeld:Destroy()
end
end
The problem now is that because I disabled the RootJoint, whenever a force like BodyVelocity is acting on the ragdolled player, the player’s torso will move first and the all the other limbs will lag behind (almost like detaching and reattaching) . Btw this is only appears on the other clients, there is no problem on the ragdolled player’s client.
Here’s a video of what I mean:
I tried setting the network ownership of the ragdolled player to the server or the attacking player, but it still makes the player’s limbs lag behind the torso.
I’ve also tried creating a clone of the ragdoll on every client using AlignOrientation and AlignPosition, but that makes the ragdoll look really weird and sometimes it stops in the middle of the air.
Does anyone know how to prevent the limbs from lagging behind torso?
Could also be an issue with that fact that the server has priority over the rootpart when you ragdoll them, so the client is still stationary while on the server it ragdolls and it’s trying to catch up by syncing the parts back to what the server sees. That’s my own guess tho.
function Ragdoll:OnStartServer()
if self:getRagdollsAmount() > 1 then return end
self.Character.Humanoid.PlatformStand = true
self.Character.Humanoid:ChangeState(Enum.HumanoidStateType.FallingDown)
local weld = Instance.new("WeldConstraint")
weld.Name = "RagdollWeld"
weld.Part0 = self.serverCharacter.rootPart
weld.Part1 = self.serverCharacter.instance.Torso
weld.Parent = self.serverCharacter.instance
self.serverCharacter.rootPart.RootJoint.Enabled = false
for _, motor in ipairs(self.Character.Instance:GetDescendants()) do
if not motor:IsA("Motor6D") then continue end
self:processMotor(motor)
end
end
function Ragdoll:OnEndServer()
if self:getRagdollsAmount() > 0 then return end
self.serverCharacter.rootPart.RootJoint.Enabled = true
self.Character.Humanoid.PlatformStand = false
self.Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
for _, motor in ipairs(self.Character.Instance:GetDescendants()) do
if table.find(ragdollNames, motor.Name) then
motor:Destroy()
end
if motor:IsA("Motor6D") and attachmentCFrames[motor.Name] then
motor.Enabled = true
end
end
end
I just rewatched the recording, in the perspective of the server and the player there is a moment (0:25) where network ownership is transferred to the player and back to the server during the ragdoll, the dummy hangs in the air for a short period for the player’s perspective. Maybe the problem is in network ownership after all?
I don’t think it’s possible unless you wanna change the network ownership. If you play games like the strongest battlegrounds, the limbs also lag behind the torso.