Ragdoll on fall?

I’m trying to make this ragdoll script detect when a player is falling (not after jumping) how would i do this? (the script is made by Stillwater on yt)

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(c)
		c:WaitForChild("Humanoid").BreakJointsOnDeath = false 
		c.Humanoid.Died:Connect(function()
			for _, v in pairs(c:GetDescendants())do
				if v:IsA("Motor6D")then 
					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.Attachment0 = a0
					b.Attachment1 = a1
					b.Parent = v.Part0 
					
					v:Destroy()
				end
			end
			c.HumanoidRootPart.CanCollide = false
		end)
	end)
end)
1 Like

Humanoid has the functions GetState() and GetStateEnabled() which can be used to check the Humanoid’s Enum.HumanoidStateType. My guess is that you’re gonna want to check if the HumanoidStateType is FallingDown, which is when the player is tripped. There’s also Freefall, but that would happen if you jump. So you could run a check every frame for Humanoid:GetStateEnabled(Enum.HumanoidStateType.FallingDown).

Or, there’s the events
Humanoid.FallingDown
Humanoid.FreeFalling
Humanoid.StateChanged
Humanoid.StateEnabledChange

Plenty of options. I don’t have an exact solution because dealing with Humanoid states is finnicky, but one of these is bound to work. Somebody with more experience with them might be able to provide a code snippet.

6 Likes

You could also do a loop that checks the players y velocity, and if the players velocity is low enough it triggers the ragdoll script.

For example
While true do
If c.Torso.Velocity.y < -40 then
— trigger the rag doll —

2 Likes