Ragdolling on death on client freezes the character

Hi! I am trying to make the character ragdoll when dying. However the character ragdolls slightly and just freezes. Even when the character respawns and I reset, the result is the same.

Heres the code in LocalScript, which is stored in StarterCharacterScripts

local char = script.Parent

script.Parent.Humanoid.Died:Once(function()
    char.HumanoidRootPart.AssemblyLinearVelocity = char.HumanoidRootPart.CFrame.LookVector * -60
    for i, v : Instance in pairs(char:GetDescendants()) do
        if v:IsA("Motor6D") then
            local socket = Instance.new("BallSocketConstraint")
            local a1 = Instance.new("Attachment")
            local a2 = Instance.new("Attachment")

            a1.Parent = v.Part0
            a2.Parent = v.Part1

            socket.Parent = v.Parent
            socket.Attachment0 = a1
            socket.Attachment1 = a2
            socket.LimitsEnabled = true
            socket.TwistLimitsEnabled = true
            socket.MaxFrictionTorque = 20

            a1.CFrame = v.C0
            a2.CFrame = v.C1

            v.Parent.Massless = true

            v:Destroy()
        end
    end
end)

Heres the code in Script, which is stored in ServerScriptService

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        char:WaitForChild("Humanoid").BreakJointsOnDeath = false
    end)
end)

Previously tried doing the ragdoll on death thing on server, which works but it has a delay so I want to do this on client

Help is appreciated!!

4 Likes

Its due to the MaxFrictionTorque property try removing it

1 Like

The MaxFrictionTorque property basically applies how much resistance to torque/rotation of the ballsocketconstraint to keep them aligned so it makes it appear the character ragdoll freezes when in reality your resisting anymore rotation for the ragdoll.

Unfortunately it’s still the same result…
image

hmmm i reply back let me copy your script

I don’t really think that this is the problem, but just in case, try removing the line that makes the parents Massless. Maybe a mismatch with the assembly root psrt could be causing an issue.

its the localscript thats the problem

1 Like

Oh okay, apparently the server gains ownership of the physics once the player dies.

Maybe you could manually set the network owner back to the client, but I’m not sure. Check out the thread tho, maybe you can find a better answer there.

2 Likes

massles isnt the problem i tested it

1 Like

yeah networkownership works so use a script instead of a local script for the ragdoll and setnetworkowner of all unachored parts of the character to the player of its character it appears smoother:

local char = script.Parent
local player=game.Players:GetPlayerFromCharacter(humanoid.Parent)

script.Parent.Humanoid.Died:Once(function()
char.HumanoidRootPart.AssemblyLinearVelocity = char.HumanoidRootPart.CFrame.LookVector * -60
for i, v : Instance in pairs(char:GetDescendants()) do
if v:IsA(“Motor6D”) then
local socket = Instance.new(“BallSocketConstraint”)
local a1 = Instance.new(“Attachment”)
local a2 = Instance.new(“Attachment”)

        a1.Parent = v.Part0
        a2.Parent = v.Part1

        socket.Parent = v.Parent
        socket.Attachment0 = a1
        socket.Attachment1 = a2
        socket.LimitsEnabled = true
        socket.TwistLimitsEnabled = true
        socket.MaxFrictionTorque = 20

        a1.CFrame = v.C0
        a2.CFrame = v.C1

        v.Parent.Massless = true

        v:Destroy()
	end
	if v:IsA("BasePart") and not v.Anchored then
		warn("y")
		v:SetNetworkOwner(player)
	end
end

end)

1 Like
local char = script.Parent
local player=game.Players:GetPlayerFromCharacter(humanoid.Parent)

script.Parent.Humanoid.Died:Once(function()
    char.HumanoidRootPart.AssemblyLinearVelocity = char.HumanoidRootPart.CFrame.LookVector * -60
    for i, v : Instance in pairs(char:GetDescendants()) do
        if v:IsA("Motor6D") then
            local socket = Instance.new("BallSocketConstraint")
            local a1 = Instance.new("Attachment")
            local a2 = Instance.new("Attachment")

            a1.Parent = v.Part0
            a2.Parent = v.Part1

            socket.Parent = v.Parent
            socket.Attachment0 = a1
            socket.Attachment1 = a2
            socket.LimitsEnabled = true
            socket.TwistLimitsEnabled = true
            socket.MaxFrictionTorque = 20

            a1.CFrame = v.C0
            a2.CFrame = v.C1

            v.Parent.Massless = true

            v:Destroy()
		end
		if v:IsA("BasePart") and not v.Anchored then
			warn("y")
			v:SetNetworkOwner(player)
		end
    end
end)
1 Like

thanks so much!!! it works as intended now :smiley:

oh i didnt know server does that… thank you so much!

yeah networkownership works only on the server

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.