Need help with Ragdoll Colliders

Hello, I need help with a ragdoll script issue, this script is designed to be toggled, and the issue I’m running into is that when the player gets unragdolled they walk through others players, which is an issue.
Heres the code:

if v:IsA(“BasePart”) then
local Collider = Instance.new(“Part”)
Collider.Size = v.Size / Vector3.new(15,15,15)
Collider.CFrame = v.CFrame
Collider.CanCollide = true
Collider.Anchored = false
Collider.Transparency = 1
local w = Instance.new(“Weld”)
w.Part0 = v
w.Part1 = Collider
w.C0 = CFrame.new()
w.C1 = w.Part1.CFrame:toObjectSpace(w.Part0.CFrame)
w.Parent = Collider
Collider.Parent = v
–PhysicsService:SetPartCollisionGroup(v, “Colliders”)
–PhysicsService:SetPartCollisionGroup(Collider, “Colliders”)
BaseParts[Character][v] = Collider
end

1 Like

I don’t usually use ragdolls, this sounds interesting… Are ballsocket constraints the way to go? What is the problem exactly?

Yes, ballsocketconstraints are what I use. The problem is that the ragdoll is stiff, and feels clunky. Also the camera shakes when you get ragdolled on the floor (the camera shake occurs when i disable the physics collisions part)

Is this a module? You stated above the problem was that you can walk through other players after the ragdoll mode is no longer active. If it’s a module we can not help you with that problem unless you show the whole module.

Ah ok. I see what you mean, do you know understand the issue at hand?

I think you mean this bud:

local Motors = {}
local BaseParts = {}

local module = {}
local PhysicsService = game:GetService("PhysicsService")
PhysicsService:CreateCollisionGroup("Colliders")
PhysicsService:CollisionGroupSetCollidable("Colliders", "Colliders", false)

module.ragdoll = function(Character, Enabled)
	if not Character or (Character and not (Character:FindFirstChild("Humanoid") and Character:FindFirstChild("HumanoidRootPart"))) then
		return nil
	end
	if Enabled and not Motors[Character] and not BaseParts[Character] then
		Motors[Character] = {}
		BaseParts[Character] = {}
		Character.Humanoid.PlatformStand = true
		for i,v in pairs(Character:GetDescendants()) do
			if v:IsA("Motor6D") then
				local socket = Instance.new("PrismaticConstraint")
				local part0 = v.Part0
				local part1 = v.Part1
				
				Motors[Character][v] = {Part0 = v.Part0, Socket = socket}
				
				local attachment = Instance.new("Attachment")
				attachment.CFrame = v.C0
				attachment.Parent = part0
				
				local attachment1 = Instance.new("Attachment")
				attachment1.CFrame = v.C1
				attachment1.Parent = part1
				
				if attachment and attachment1 then
					socket.Attachment0, socket.Attachment1 = attachment, attachment1
					socket.Parent = v.Parent
					v.Part0 = nil;
				end
				
			end
			if v:IsA("BasePart") then
				local Collider = Instance.new("Part")
				Collider.Size = v.Size / Vector3.new(15,15,15)
				Collider.CFrame = v.CFrame
				Collider.CanCollide = true
				Collider.Anchored = false
				Collider.Transparency = 1
				local w = Instance.new("Weld")
				w.Part0 = v
				w.Part1 = Collider
				w.C0 = CFrame.new()
				w.C1 = w.Part1.CFrame:toObjectSpace(w.Part0.CFrame)
				w.Parent = Collider
				Collider.Parent = v
				PhysicsService:SetPartCollisionGroup(v, "Colliders")
				PhysicsService:SetPartCollisionGroup(Collider, "Colliders")
				BaseParts[Character][v] = Collider
			end
		end
	elseif not Enabled and Motors[Character] then
		
		Character.Humanoid.PlatformStand = false
		Character.HumanoidRootPart.CFrame = CFrame.new(Character.HumanoidRootPart.CFrame.p)

		for i,v in pairs(Motors[Character]) do
			i.Part0 = v.Part0
			v.Socket.Attachment0:Destroy()
			v.Socket.Attachment1:Destroy()
			v.Socket:Destroy()
		end
		
		for i,v in pairs(BaseParts[Character]) do
			v:Destroy()
		end
		
		Motors[Character] = nil
		BaseParts[Character] = nil
	end
end

return module

Thank you for correcting my error.
Also, PrimsaticConstraint should be replaced with Ballsocket.

1 Like