Can't knockback ragdolled character on reset

I’m trying to achieve a ragdoll knockback death effect when the character resets, but instead it looks like this https://i.gyazo.com/0885d822e7feced1a3a2821bbeef8bb0.mp4

I don’t know what is causing the issue. How do I fix this?

my server script

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.Humanoid.BreakJointsOnDeath = false
	end)
end)

my local script

local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid: Humanoid = character.Humanoid
local hrp: BasePart = character.HumanoidRootPart


humanoid.Died:Connect(function()
    --ragdoll
	for i, v in pairs(character:GetDescendants()) do
		if v:IsA("Motor6D") and v.Name ~= "RootJoint" then
			local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
			a0.Name = "a"
			a1.Name = "a"
			a0.CFrame = v.C0
			a1.CFrame = v.C1
			a0.Parent = v.Part0
			a1.Parent = v.Part1

    -- Default is just a default ballsocket constraint with LimitsEnabled and TwistLimitsEnabled
    -- set to true, with the default numbers
			local ballsocketConstraint = script.Default:Clone()
			ballsocketConstraint.Attachment0 = a0
			ballsocketConstraint.Attachment1 = a1
			ballsocketConstraint.Name = "bsc"
			ballsocketConstraint.Parent = v.Parent

			v.Enabled = false
		elseif v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then 
			local NC  = Instance.new("NoCollisionConstraint") 
			NC.Name   = "ncc"
			NC.Part0  = v
			NC.Part1  = character.HumanoidRootPart
			NC.Parent = character.Torso
		end
	end
    --knockback
	hrp:ApplyImpulse(hrp.CFrame.LookVector * -150 * hrp.AssemblyMass)
end)

A recent change gives the server network ownership of dead characters. The impulse has to be applied by the server.

2 Likes

It doesn’t have to be done that way, you can also override this behavior by explicitly calling character:SetNetworkOwner(player), as the behavior is only part of the automatic network assignment algorithm, though then your game may be open to the bad behaviors which it’s intended to prevent (exploiters being able to arbitrarily position the broken parts of your character between death and respawn).

2 Likes

This did not work at all. I connected a humanoid.Died event on the server and applied the impulse there, but I got the same result as the video I linked. I also tried doing it through a remote event from the client to server, but that didn’t work either.

Setting network ownership of the humanoidRootPart to the player on the server and having the player apply the impulse locally worked. But when you mention bad behaviors, can it really be that bad for a game if I do this way?

This was also the result. It worked perfectly.
https://i.gyazo.com/68a8da46aa06cb0bda8b31e8477eb297.mp4

If your characters break joints on death then it lets exploiters position the parts of their character in an arbitrary way after they die before they respawn. If your characters don’t break joints (which it sounds like in your case) then there shouldn’t be any issue.

1 Like

ok. Good to know. Ty. I’ll mark your answer as the solution

Oh, and just one more question. If BreakJointsOnDeath was true and exploiters did happen to position the parts of their character in an arbitrary way after they die, would their parts get destroyed along with their old character the moment their new character respawns?

Yeah, there’s just a brief period where they have complete control of the part positions.

1 Like

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