Ragdoll module not working

I am making a ragdoll modulescript so I can easily toggle a ragdoll on a character for explosions and stuns, I am using the same method for ragdolls that I used in another game although it was in a serverscript, but it doesn’t seem to work anymore, the characters limbs are still very static and it just looks like the player is in the platform stand state, anyone know why? Here is the function:

function Ragdoll.TempRagdoll(char, length)
	for _, v in pairs(char:GetDescendants()) do
		if v:IsA("Motor6D") and v.Name ~= "Neck" then
			local humanoid = char.Humanoid
			local plr = game.Players:GetPlayerFromCharacter(char)
			local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
			a0.CFrame = v.C0
			a1.CFrame = v.C1
			a0.Parent = v.Part0
			a1.Parent = v.Part1

			local b = Instance.new("BallSocketConstraint")
			b.LimitsEnabled = true
			b.Radius = 10
			b.UpperAngle = 7.5
			b.Attachment0 = a0
			b.Attachment1 = a1
			b.Parent = v.Parent
			b.TwistLimitsEnabled = true

			humanoid.PlatformStand = true

			v.Enabled = false
			game.ReplicatedStorage.Events.ChangeState:FireAllClients(plr, "Ragdoll")
			wait(length)
			game.ReplicatedStorage.Events.ChangeState:FireAllClients(plr, "GetUp")
			humanoid.PlatformStand = false

			for _, v in pairs(char:GetDescendants()) do
				if v:IsA("Motor6D") then
					v.Enabled = true
				end
			end

			for _, v in pairs(char:GetDescendants()) do
				if v:IsA("BallSocketConstraint") then
					v:Destroy()
				end
			end
		end
	end
end
1 Like

Are you modifying the network ownership of the player’s character in some way?

No not that I am aware of, the script works fine in a server script but as soon as I converted it for use in a module it just stopped working.

Is the script you provided the entire module? A module is supposed to return something at the end of it.

local Ragdoll = {}

function Ragdoll.TempRagdoll(char, length)
	for _, v in pairs(char:GetDescendants()) do
		if v:IsA("Motor6D") and v.Name ~= "Neck" then
			local humanoid = char.Humanoid
			local plr = game.Players:GetPlayerFromCharacter(char)
			local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
			a0.CFrame = v.C0
			a1.CFrame = v.C1
			a0.Parent = v.Part0
			a1.Parent = v.Part1

			local b = Instance.new("BallSocketConstraint")
			b.LimitsEnabled = true
			b.Radius = 10
			b.UpperAngle = 7.5
			b.Attachment0 = a0
			b.Attachment1 = a1
			b.Parent = v.Parent
			b.TwistLimitsEnabled = true

			humanoid.PlatformStand = true

			v.Enabled = false
			game.ReplicatedStorage.Events.ChangeState:FireAllClients(plr, "Ragdoll")
			wait(length)
			game.ReplicatedStorage.Events.ChangeState:FireAllClients(plr, "GetUp")
			humanoid.PlatformStand = false

			for _, v in pairs(char:GetDescendants()) do
				if v:IsA("Motor6D") then
					v.Enabled = true
				end
			end

			for _, v in pairs(char:GetDescendants()) do
				if v:IsA("BallSocketConstraint") then
					v:Destroy()
				end
			end
		end
	end
end

return Ragdoll

Yes it does return at the end

local Ragdoll = {}

function Ragdoll.TempRagdoll(char, length)
	for _, v in pairs(char:GetDescendants()) do
		if v:IsA("Motor6D") and v.Name ~= "Neck" then
			local humanoid = char.Humanoid
			local plr = game.Players:GetPlayerFromCharacter(char)
			local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
			a0.CFrame = v.C0
			a1.CFrame = v.C1
			a0.Parent = v.Part0
			a1.Parent = v.Part1

			local b = Instance.new("BallSocketConstraint")
			b.LimitsEnabled = true
			b.Radius = 10
			b.UpperAngle = 7.5
			b.Attachment0 = a0
			b.Attachment1 = a1
			b.Parent = v.Parent
			b.TwistLimitsEnabled = true

			humanoid.PlatformStand = true

			v.Enabled = false
			game.ReplicatedStorage.Events.ChangeState:FireAllClients(plr, "Ragdoll")
			wait(length)
			game.ReplicatedStorage.Events.ChangeState:FireAllClients(plr, "GetUp")
			humanoid.PlatformStand = false

			for _, v in pairs(char:GetDescendants()) do
				if v:IsA("Motor6D") then
					v.Enabled = true
				end
			end

			for _, v in pairs(char:GetDescendants()) do
				if v:IsA("BallSocketConstraint") then
					v:Destroy()
				end
			end
		end
	end
end

return Ragdoll

Have you debugged by adding a print inside the function to check if it is being correctly executed from within the script(s) which is/are requiring it?

Everything prints fine

image

This might help How to make a R15 Ragdoll game Mobile support + push tool - YouTube

My game is R6, and I am not looking for a keybind ragdoll kit. I am making a configurable ragdoll module that can be temporarily activated for a short period of time (like for example when hit by a grenade blast)

1 Like

Well, I can wish you nothing but luck