Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a script that makes a player ragdoll when it takes damage and gets back up?

Asked by 3 years ago
Edited 3 years ago

I've tried many different ways of going about this. A lot of tutorials on youtube only have it occur when the player dies. I tried changing the humanoid.Died event to humanoid.HealthChanged but that didn't work, the arms were flailing but the player was still normal. I tried humanoid.GetPropertyChangedSignal("Health)" and I was just frozen in place. I tried using these with several different ragdoll scripts made from other people. Not so sure how I should go about this.

game:GetService("Players").PlayerAdded:Connect(function (plr)
    plr.CharacterAdded:Connect(function (char)
        local humanoid = char:WaitForChild("Humanoid")
        humanoid:GetPropertyChangedSignal("Health"):Connect(function()
            if char:FindFirstChild("HumanoidRootPart") then
                //ragdoll script
            end

At the end of the ragdoll script I tried adding this from a "Press R to ragdoll" script I found to see if it would change the ragdoll state, didn't really do anything though:

wait(4)
local setEnabled = humanoid:GetState() ~= Enum.HumanoidStateType.Physics
humanoid:ChangeState(humanoid:ChangeState(setEnabled and    Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp))
char.Animate.Disabled = setEnabled
if setEnabled then
    for _,v in pairs(humanoid:GetPlayingAnimationTracks()) do
        v:Stop(0)
    end
end

Is there a problem with the way I'm firing the event or is it to do with the ragdoll script as a whole?

Answer this question