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)
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).
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?
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.
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?