My ragdoll system isn't unragdolling and is really janky

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want my ragdoll system to ragdoll the player when called, wait for the specified duration, and get back up.
  2. What is the issue? Include screenshots / videos if possible!
    They don’t unragdoll, and look weird, similar to how https://devforum.roblox.com/t/my-ragdollin-system-isnt-working/2899586’s issue was.
  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    ai and yes i did
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local module = {}

local Players = game:GetService("Players")

local active = {}

local attachments = {
	["Neck"] = {
		CFrame.new(0,1,0,-1,0,0,0,0,1,0,1,0),
		CFrame.new(0,-0.5,0,-1,0,0,0,0,1,0,1,0)
	},

	["Left Shoulder"] = {
		CFrame.new(-1.3,0.75,0),
		CFrame.new(0.2,0.75,0)
	},

	["Right Shoulder"] = {
		CFrame.new(1.3,0.75,0),
		CFrame.new(-0.2,0.75,0)
	},

	["Left Hip"] = {
		CFrame.new(-0.5,-1,0),
		CFrame.new(0,1,0)
	},

	["Right Hip"] = {
		CFrame.new(0.5,-1,0),
		CFrame.new(0,1,0)
	},
}


local function makeConstraints(char)

	local data = {
		motors = {},
		constraints = {}
	}

	for _,motor in ipairs(char:GetDescendants()) do

		if motor:IsA("Motor6D") then

			data.motors[motor] = motor.Enabled

			local info = attachments[motor.Name]

			if info then

				local a0 = Instance.new("Attachment")
				a0.Name = "RagdollAttachment"
				a0.CFrame = info[1]
				a0.Parent = motor.Part0


				local a1 = Instance.new("Attachment")
				a1.Name = "RagdollAttachment"
				a1.CFrame = info[2]
				a1.Parent = motor.Part1


				local socket = Instance.new("BallSocketConstraint")
				socket.Name = "RagdollConstraint"
				socket.Attachment0 = a0
				socket.Attachment1 = a1
				socket.LimitsEnabled = true
				socket.UpperAngle = 90
				socket.Parent = motor.Part0


				table.insert(data.constraints,socket)

			end

			motor.Enabled = false
		end
	end

	active[char] = data
end


local function clear(char)

	local data = active[char]

	if not data then
		print("[Ragdoll] NO DATA")
		return
	end


	for _,v in ipairs(data.constraints) do
		if v then
			v:Destroy()
		end
	end


	for motor,state in pairs(data.motors) do

		if motor and motor.Parent then
			motor.Enabled = state
		end

	end


	active[char] = nil

end



function module:Unragdoll(char)

	print("[Ragdoll] OFF")

	local hum = char:FindFirstChildOfClass("Humanoid")

	if not hum then return end


	clear(char)


	hum.AutoRotate = true
	hum.PlatformStand = false

	task.wait()

	hum:ChangeState(Enum.HumanoidStateType.GettingUp)


	print("[Ragdoll] RESTORED")

end



function module:Ragdoll(char,time)

	print("[Ragdoll] ON")

	local hum = char:FindFirstChildOfClass("Humanoid")

	if not hum then
		print("[Ragdoll] NO HUMANOID")
		return
	end


	makeConstraints(char)


	hum.AutoRotate = false
	hum:ChangeState(Enum.HumanoidStateType.Physics)


	print("[Ragdoll] ACTIVE")


	if time then

		task.spawn(function()

			print("[Ragdoll] TIMER",time)

			task.wait(time)

			print("[Ragdoll] TIMER END")

			if char.Parent then
				module:Unragdoll(char)
			end

		end)

	end

end


return module

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

My scripting is a lot of the times a hot mess
If anyone can find something that would be easy to use and not a bad ragdoll module, please do let me know about it

1 Like

Video of bug

1 Like

have you tried… removing the constraints you made after unragdolling?

1 Like

The module never gets to that point. That’s why I created a topic. I’m not the best at scripting and can’t debug my scripts well, though. I’m using the Roblox Rocket Launcher script (i modified it) for my ragdolling and the rocket isn’t kept alive.

19:01:02.139 [Ragdoll] ON - Server - ragdoll:156
19:01:02.139 [Ragdoll] ACTIVE - Server - ragdoll:173
19:01:02.140 [Ragdoll] TIMER 3 - Server - ragdoll:180

local BLAST_RADIUS = 10
local BLAST_DAMAGE = 60
local BLAST_FORCE = 1500

local DESTRUCTION_RADIUS = 10
local VOXEL_SIZE = 1
local DEBRIS_COUNT = 75
local DEBRIS_FORCE = 180

local IGNORE_LIST = {
	rocket = true,
	handle = true,
	effect = true,
	water = true
}

local DebrisService = game:GetService("Debris")
local PlayersService = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")

local VoxelDestruction = require(game.ReplicatedStorage:WaitForChild("VoxelDestruction"))
local ragdollmodule = require(game.ReplicatedStorage:WaitForChild("ragdoll"))

local Rocket = script.Parent
local CreatorTag = Rocket:WaitForChild("creator")
local SwooshSound = Rocket:WaitForChild("Swoosh")

local TaggedHumanoids = {}

local function ApplyTags(target)
	while target:FindFirstChild("creator") do
		target.creator:Destroy()
	end

	local clone = CreatorTag:Clone()
	clone.Parent = target
	DebrisService:AddItem(clone, 1.5)
end

local function FindCharacterAncestor(subject)
	if subject and subject ~= workspace then
		local humanoid = subject:FindFirstChildOfClass("Humanoid")
		if humanoid then
			return subject, humanoid
		end
		return FindCharacterAncestor(subject.Parent)
	end
end

local function IsInTable(tab, value)
	for _, v in ipairs(tab) do
		if v == value then
			return true
		end
	end
	return false
end

local function DestroyArea(position)
	local hitbox = Instance.new("Part")
	hitbox.Name = "RocketDestructionHitbox"
	hitbox.Shape = Enum.PartType.Ball
	hitbox.Size = Vector3.new(DESTRUCTION_RADIUS * 2, DESTRUCTION_RADIUS * 2, DESTRUCTION_RADIUS * 2)
	hitbox.Transparency = 1
	hitbox.Anchored = true
	hitbox.CanCollide = false
	hitbox.CanQuery = true
	hitbox.Position = position
	hitbox.Parent = workspace

	local params = OverlapParams.new()
	params.FilterType = Enum.RaycastFilterType.Include
	params.FilterDescendantsInstances = CollectionService:GetTagged("Breakable")
	params.RespectCanCollide = false

	local parts = workspace:GetPartsInPart(hitbox, params)

	if #parts > 0 then
		local debris = VoxelDestruction.Destroy(hitbox, params, VOXEL_SIZE, DEBRIS_COUNT, 10)

		for _, piece in ipairs(debris) do
			if piece:IsA("BasePart") then
				local direction = piece.Position - position

				if direction.Magnitude < 1 then
					direction = Vector3.new(
						math.random(-100,100),
						math.random(30,100),
						math.random(-100,100)
					)
				end

				local bv = Instance.new("BodyVelocity")
				bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
				bv.Velocity = direction.Unit * DEBRIS_FORCE + Vector3.new(0,40,0)
				bv.Parent = piece

				DebrisService:AddItem(bv, .25)
			end
		end
	end

	hitbox:Destroy()
end

local function ExplosionHit(hitPart, hitDistance, center)
	local character, humanoid = FindCharacterAncestor(hitPart.Parent)

	if character then
		local myPlayer = CreatorTag.Value

		if myPlayer and not myPlayer.Neutral then
			local player = PlayersService:GetPlayerFromCharacter(character)

			if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
				return
			end
		end
	end

	if humanoid and humanoid.Health > 0 then
		if not IsInTable(TaggedHumanoids, humanoid) then
			table.insert(TaggedHumanoids, humanoid)

			ApplyTags(humanoid)
			humanoid:TakeDamage(BLAST_DAMAGE)
			ragdollmodule:Ragdoll(character, 3)

			local root = character:FindFirstChild("Torso")

			if root then
				local bv = Instance.new("BodyVelocity")
				bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
				bv.Velocity = (center - root.Position).Unit * -180 + Vector3.new(0,80,0)
				bv.Parent = root

				DebrisService:AddItem(bv, .15)
			end
		end

		task.wait(5)
		print("kept alive script")
	else
		if hitPart.Name ~= "Handle" then
			hitPart:BreakJoints()

			local force = Instance.new("BodyForce")
			force.Force = (hitPart.Position - center).Unit * BLAST_FORCE * hitPart:GetMass()
			force.Parent = hitPart

			DebrisService:AddItem(force, .1)
		end
	end
end

local function Explode()
	local position = Rocket.Position

	local explosion = Instance.new("Explosion")
	explosion.BlastPressure = 0
	explosion.BlastRadius = BLAST_RADIUS
	explosion.ExplosionType = Enum.ExplosionType.NoCraters
	explosion.Position = position
	explosion.Parent = workspace

	DestroyArea(position)

	explosion.Hit:Connect(function(part, distance)
		ExplosionHit(part, distance, position)
	end)

	Rocket.Transparency = 1

	task.wait(5)
	Rocket:Destroy()
end

local function OnTouched(otherPart)
	if not Rocket or not otherPart then
		return
	end

	if IGNORE_LIST[string.lower(otherPart.Name)] then
		return
	end

	local player = CreatorTag.Value

	if player then
		if player.Character and player.Character:IsAncestorOf(otherPart) then
			return
		end

		if not player.Neutral then
			local character = FindCharacterAncestor(otherPart.Parent)
			local target = PlayersService:GetPlayerFromCharacter(character)

			if target and target.TeamColor == Rocket.BrickColor then
				return
			end
		end
	end

	Explode()
end

SwooshSound:Play()
Rocket.Touched:Connect(OnTouched)
1 Like

I mean your probaby better off using other peoples ragdoll system and adjust it to your needs. Goodluck though :+1: