Trying to have player Ragdoll after getting hit

Here is the code.

 local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
			 local BodyVelocity = Instance.new("BodyVelocity", HumanoidRootPart)
            BodyVelocity.Velocity = Vector3.new(0,10,0) + HumanoidRootPart.CFrame.LookVector *  200
				Humanoid.Ragdoll:Connect(function(True)
				
				
					            wait(0.5)
					
                    Humanoid.Ragdoll:Connect(function(False)
				            BodyVelocity:Destroy()

I’m trying too have the person who gets knocked back from this to ragdoll, but I have no idea how. Could someone help? I’d greatly appreciate it

2 Likes

Try using:

Humanoid.ChangeState(Enum.HumanoidStateType.Ragdoll)
1 Like

Try getting the humanoid in the character:

local Humanoid = Character.Humanoid
-- or :FindFirstChild or :WaitForChild

From here, you can make the character ragdoll by using Humanoid:ChangeState to change to a HumanoidStateType enum:

Humanoid:ChangeState(Enum.HumanoidStateType.FallingDown)

You can also use Physics or PlatformStanding. I think the Ragdoll enum won’t be very responsive, please prove me wrong.

You can also change the PlatformStand property:

Humanoid.PlatformStand = true

And you can also use the cool ragdoll resource if you want the character to turn into the traditional definition of a ragdoll:

3 Likes

Im tryin but it keeps saying Im indexing Humanoid with Nil. I did
local character = Game.Players.localPlayers.Character
local Humanoid = character:WaitForChild(“Humanoid”)
This isnt exact with capitals and w/e just an example of what I tried but it keeps saying its nil. ANyw ideas?

Heres waht i did

local Character = game.Players.LocalPlayer.Character
local Humanoid = Character.Humanoid

it keeps saying [attempt to index nil with ‘Character’

I’ve tried that aswell its not working no idea why.

When are you trying to run this code? If you run this code right when the player joins, they won’t have a character yet, and if you run it after they’ve died, the character will be different.

Player | Documentation - Roblox Creator Hub is an event that passes a character argument for you to use, and every time the character changes the event fires again.

And are you running this code on the server or client?

This part is being run on the server, is that an issue?

If it’s on the server, you should use the PlayerAdded event:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        -- do ragdoll stuff here

    end)
end)
2 Likes

You cannot use LocalPlayer in a server script. Only in local scripts. Maybe show more of the code to see where it should be placed.

1 Like