Ragdolled Player Doesnt Fall Over

Trying to achieve a ragdoll effect similar to Grand Piece Online’s

However, when the ragdoll is activated on an NPC, they don’t fall over at all, even though all their limbs are numb. How can I make sure the NPC / player falls over when they ragdoll? Here is the logic that controls the ragdoll:

-- This function runs for all players and npcs
function module.BuildRag(character)
	local humanoid = character:WaitForChild("Humanoid")
	humanoid.BreakJointsOnDeath = false
	
	humanoid.Died:Once(function()
		DoRagdoll(character, true)
	end)

	local rootPart = character:FindFirstChild("HumanoidRootPart")
	if rootPart then
		rootPart.CanCollide = false
	end
	
	task.spawn(function()
		if players:GetPlayerFromCharacter(character) ~= nil then
			return -- we dont want it to set network for player, as we dont know how that will effect things. should be done by server already
		end
		
		pcall(function()
			for _, bp in character:GetDescendants() do
				if bp:IsA("BasePart") then
					if bp.Anchored then continue end
					bp:SetNetworkOwner(nil)
				end
			end
		end)
	end)

	local attachmentMap = buildAttachmentMap(character)
	local ragdollConstraints = buildConstraints(attachmentMap)
	local collisionFilters = buildCollisionFilters(attachmentMap, character.PrimaryPart)

	collisionFilters.Parent = ragdollConstraints
	ragdollConstraints.Parent = character
end

-- This controls the ragdoll
function setRagdollEnabled(humanoid, isEnabled)
	local ragdollConstraints = humanoid.Parent:FindFirstChild("RagdollConstraints")

	for _, constraint in pairs(ragdollConstraints:GetChildren()) do
		if constraint:IsA("Constraint") then
			local rigidJoint = constraint.RigidJoint.Value
			local expectedValue = (not isEnabled) and constraint.Attachment1.Parent or nil

			if rigidJoint.Part1 ~= expectedValue then
				rigidJoint.Part1 = expectedValue 
			end
		end
	end
end

function DoRagdoll(character, bool)
	assert(character:IsA("Model"))
	local humanoid = character:WaitForChild("Humanoid") :: Humanoid
	
	local state = if bool then Enum.HumanoidStateType.Physics else Enum.HumanoidStateType.GettingUp
	humanoid:ChangeState(state)
	
	setRagdollEnabled(humanoid, bool)
end


Heres what my ragdoll looks like:

I had it working a while ago, but it no longer works. Heres what it used to look like

I’ve also tried this solution, where you set PlatformStand to true rather than changing humanoid state type. Doesn’t work however and achieves the same effect

Try setting platformstand to true, and setting the Physics state type to false. Or maybe they’re simply not falling over and you need to push them over with applyimpulse. Although, that doesn’t seem like the case considering they fell over before.

1 Like

Have tried this, still won’t fall down.

Turns out I had an outside script that Anchored the HumanoidRootPart right before the ragdoll, which meant the character couldn’t fall over properly. Make sure Anchored is false!!

Really strange this doesn’t work for actual players, this was working only for NPCs. Anyone have any ideas? The root part of player’s character is unanchored

Solved this. I tried setting Humanoid.PlatformStand to true but it still wouldn’t work. Putting it in a loop and setting it to true 10 times solved it for me even thought it’s sort of a hacky way.

Since humanoid state is controlled by the client, I tried instead to just change the state on the client, rather than the server, and that works fine

Key sentence in this is “humanoid state types are controlled from the client and that causes a lot of issues as characters are also client controlled”

Must haves for successful ragdoll:

  • Unanchored humanoid root part
  • Changing state on the client or using platform stand on the server (unless and npc, where state can be changed on server since server has network ownership)
1 Like

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