I’m trying to add humanoid ragdolls to my game, but CanCollide is false for every part, only on the client. No idea why this happens. I want every limb, including the torso and head, to collide with everything. But since i set the NetworkOwnership with my grab script, they don’t collide.
function module.NpcRagdoll(char: Model)
local humanoid = char:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
humanoid.BreakJointsOnDeath = false
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
humanoid.PlatformStand = true
local function collideChildren()
for _, part in ipairs(char:GetChildren()) do
if part:IsA("BasePart") then
part:SetNetworkOwner(nil)
part.Anchored = false
part.CanCollide = true
part.CollisionGroup = "RagdollParts"
print("Set " .. part.Name .. "'s collision")
end
end
end
collideChildren()
for _, joint in ipairs(char:GetDescendants()) do
if joint:IsA("Motor6D") then
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Name = joint.Name .. "_A0"
a2.Name = joint.Name .. "_A1"
a1.CFrame = joint.C0
a2.CFrame = joint.C1
a1.Parent = joint.Part0
a2.Parent = joint.Part1
local constraint
if joint.Name == "Neck" or joint.Name == "Root" then
constraint = Instance.new("HingeConstraint")
else
constraint = Instance.new("BallSocketConstraint")
constraint.TwistLimitsEnabled = true
constraint.LimitsEnabled = true
end
constraint.Attachment0 = a1
constraint.Attachment1 = a2
constraint.Name = joint.Name .. "_RagdollConstraint"
constraint.Parent = joint.Parent
joint.Enabled = false
end
end
collideChildren()
end