Ragdoll system not working right

Im attempting to make a ragdoll system for a fighting game Im making, but for the life of me i cant figure out why some of these bugs im getting happen.

So I got the ragdolling to work and then thought id add some collision to the parts so that they wouldn’t clip through the ground. So i did that by welding parts that are the same size as the player limbs, onto the limbs. I made sure that they wouldn’t collide with each other by making them part of a specific collision group. But for whatever reason it keeps having this bug where when the player gets up, they get thrown upwards and then when they fall the character gets stuck in place no matter what i do. So you have to reset.

I made the whole system by just barely following a tutorial. I thought i knew enough to do it without copying it directly because i’ve made this sorta thing before and it mostly worked out. But idk you tell me what im doing wrong here i guess.

Tutorial i slightly followed: https://www.youtube.com/watch?v=RnXKmpmEJ3s&ab_channel=MajesticDev

Module:

local Ragdoll = {}

function Ragdoll.Activate(Character)
	local Humanoid = Character:FindFirstChild("Humanoid")
	
	if not Humanoid then return end
	
	if Character.Ragdoll.Value then return end
	
	for i, v in pairs(Character:GetDescendants()) do
		if v:IsA("Motor6D") then
			local a0 = Instance.new("Attachment", v.Part0)

			local a1 = Instance.new("Attachment", v.Part1)

			local socket = Instance.new("BallSocketConstraint", v.Part0)

			a0.CFrame = v.C0
			a1.CFrame = v.C1

			socket.Attachment0 = a0
			socket.Attachment1 = a1
			
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true

			v.Enabled = false
		end
		if v:IsA("Part") and v.Parent == Character then
			local Col = Instance.new("Part", Character)
			local Weld = Instance.new("Weld", Col)
			
			Col.Size = v.Size
			Col.CFrame = v.CFrame
			
			if workspace.DebugMode.Value then
				Col.Transparency = .5
				Col.BrickColor = BrickColor.Yellow()
			else
				Col.Transparency = 1
			end
			
			Col.CollisionGroup = "Player Parts"
			
			Col.Name = "Col"
			
			Weld.Part0 = v
			Weld.Part1 = Col
		end
	end
	
	Humanoid.PlatformStand = true
	Humanoid.AutoRotate = false
	
	Character.Ragdoll.Value = true
end

function Ragdoll.Disable(Character)
	local Humanoid = Character:FindFirstChild("Humanoid")

	if not Humanoid then return end

	if not Character.Ragdoll.Value then return end

	for i, v in pairs(Character:GetDescendants()) do
		if v:IsA("BallSocketConstraint") then
			v.Attachment0:Destroy()
			v.Attachment1:Destroy()
			v:Destroy()
		end
		if v:IsA("Motor6D") then
			v.Enabled = true
		end
		if v.Name == "Col" then
			v:Destroy()
		end
	end
	
	Humanoid.PlatformStand = false
	Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
	Humanoid.AutoRotate = true
	
	Character.Ragdoll.Value = false
end

return Ragdoll

the script used in a part i use to ragdoll the player:

local debris = game:GetService("Debris")
local Part = script.Parent

Part.Touched:Connect(function(Other)
	local Humanoid = Other.Parent:FindFirstChild("Humanoid")
	if not Humanoid then return end
	local Character = Humanoid.Parent
	
	local Hrp = Character:FindFirstChild("HumanoidRootPart")
	
	print(Character.Name)
	
	RagdollModule.Activate(Character)
	
	local atc = Instance.new("Attachment", Hrp)
	local lv = Instance.new("LinearVelocity", Hrp)
	
	lv.MaxForce = math.huge
	lv.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
	lv.VectorVelocity = Vector3.new(30,30,30)
	lv.Attachment0 = atc
	
	debris:AddItem(lv, .1)
	debris:AddItem(atc, .1)
	
	task.wait(3)
	RagdollModule.Disable(Character)	
end)

The code in script service i use to change player collision and add a ragdoll bool value to players:

local Players = game:GetService("Players")


Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local RagdollValue = Instance.new("BoolValue", Character)
		RagdollValue.Value = false
		RagdollValue.Name = "Ragdoll"
		Character:FindFirstChild("Humanoid").BreakJointsOnDeath = false
		for i, part in pairs(Character:GetChildren()) do
			if part:IsA("Part") then
				part.CollisionGroup = "Player Parts"
			end
		end
	end)
end)

And last and definitely least in terms of size, the script i put in character scripts based on the tutorial that i thought would help with my character being thrown upwards:

local character = script.Parent

local hum =  character:WaitForChild("Humanoid")

hum:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)

Any info is greatly appreciated! Im sorry i couldn’t upload any footage and had to send abunch of code but roblox wasn’t letting me upload a video to the post.

nvm i sorta figured it out. I just removed the last line on the local script.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.