I know having physics in the server can be weird, but I want the ragdoll to atleast align and update with the humanoidrootpart, here’s a picture of what I mean.
Here’s the ragdoll code.
-- Ragdoll Function
local function Ragdoll(character, killCharacter)
-- Variables
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
local hrp = character:FindFirstChild("HumanoidRootPart")
-- Kill
humanoid:SetAttribute("RequiresNeck", humanoid.RequiresNeck)
humanoid.RequiresNeck = killCharacter or false
-- Ragdoll Rigging
for _,descendant in ipairs(character:GetDescendants()) do
if descendant:IsA("Motor6D") and (descendant.Part0 ~= hrp) then
-- Attachments
if not descendant.Parent:FindFirstChild(descendant.Name .. "RigAttachment") then
local Attachment = Instance.new("Attachment")
Attachment.Name = (descendant.Name .. "RigAttachment")
Attachment.CFrame = descendant.C1
Attachment.Parent = descendant.Part1
Attachment = Attachment:Clone()
Attachment.CFrame = descendant.C0
Attachment.Parent = descendant.Part0
end
-- Socket
local Socket = Instance.new("BallSocketConstraint")
Socket.Attachment0 = descendant.Part0:FindFirstChild(descendant.Name .. "RigAttachment")
Socket.Attachment1 = descendant.Part1:FindFirstChild(descendant.Name .. "RigAttachment")
Socket.LimitsEnabled = true
Socket.TwistLimitsEnabled = true
Socket.Name = (descendant.Name .. "Joint")
Socket.Parent = descendant.Parent
-- Collision
local collision = Instance.new("NoCollisionConstraint")
collision.Part0 = descendant.Part0
collision.Part1 = descendant.Part1
collision.Parent = descendant.Parent
-- Motor6D
descendant.Enabled = false
end
end
for i,v in pairs(character:GetChildren()) do
if v:IsA("BasePart") then
local partclone = v:Clone()
v.CanCollide = false
partclone:ClearAllChildren()
partclone.Size = Vector3.new(1,1,.5)
partclone.Parent = v
partclone.Transparency = 1
partclone.Name = "Joint"
partclone.CanCollide = true
local WELD = Instance.new("Weld",partclone)
WELD.Part0 = partclone
WELD.Part1 = v
end
end
humanoid.PlatformStand = true
hrp.CanCollide = false
--humanoid.AutoRotate = false
hrp:SetNetworkOwner(nil) -- sets the network owner to the server
end