How to play a sound when the player ragdolls

Greetings,

Can I please know how to trigger a script when the player ragdolls (from hitting a wall at a very high speed for example) ? Thank you!

1 Like

This would go something like this:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player:Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid:Humanoid = Character:WaitForChild("Humanoid")
		
		Humanoid.Ragdoll:Connect(function(active:boolean)
			if active then
				--[[
						Anything inside of here will be activated as soon the HumanoidState changes to "Ragdoll"
				--]]
			end
		end)
	end)
end)

>> Humanoid Documentation <<

image
>> Source <<

1 Like

Thank you, but where do I need to place this script (sorry to ask) for it to work?

You’d need to place it in a server script. I’d recommend placing it under ServerScriptService

Yea I placed it there and it doesn’t work? I placed a print on there and it didn’t print when my character fell.

Well, ‘fell’ is an entirely different Humanoid State.

As the screenshot tells the ‘Ragdoll’ HumanoidState will only occur if the Humanoid has been hit by a fast-moving object.

What you are searching for is this Humanoid State

So technically speaking this one should work then:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player:Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid:Humanoid = Character:WaitForChild("Humanoid")
		
		Humanoid.FallingDown:Connect(function(active:boolean)
			if active then
				--[[
						Anything inside of here will be activated as soon the HumanoidState changes to "FallingDown"
				--]]
			end
		end)
	end)
end)
1 Like

This works, thank you so much, sorry for not explaining correctly what I wanted to achieve, I didn’t know there are 2 states, I thought they are the same.

1 Like

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