Ragdoll low health script doesn't work properly

Hmm, im confused, any help? Im very lost right now.

if setEnabled then   
    for _,v in pairs(hum:GetPlayingAnimationTracks()) do
       v:Stop(0)
    end
end

Where do I put this? Char30limit

Instead of that, completely remove the

for _,v in pairs(hum:GetPlayingAnimationTracks()) do
     v:Stop(0)
end

inside the if statement that unragdolls the player.

So this?

if hum.Health >= 39 and dog == true then

if setEnabled then

dog = false

hum.WalkSpeed = 8

hum.JumpPower = 40

hum:ChangeState(Enum.HumanoidStateType.GettingUp)

char.Animate.Disabled = false

for _,v in pairs(hum:GetPlayingAnimationTracks()) do

v:Stop(0)

end

end

wait()

end

end

end)

That is not what I said, remove that if statement and remove the for loop inside the if statement ‘if hum.Health >= 39’.

I apologize, I am really trying here… This is what I have gotten.

if hum.Health >= 39 and dog == true then

dog = false

hum.WalkSpeed = 8

hum.JumpPower = 40

hum:ChangeState(Enum.HumanoidStateType.GettingUp)

char.Animate.Disabled = false

end

end

wait()

end)

Don’t worry I’m here to help you 'til you got it. And yes, try that script now and tell me the outcome please.

I tried it, and I stayed ragdolled. Looking at the code im going off of it should be working, but im not sure?

local character = script.Parent
local humanoid = character.Humanoid

game:GetService("ContextActionService"):BindAction("Ragdoll me", function(_,input)
	if input == Enum.UserInputState.Begin then
		local setEnabled = humanoid:GetState() ~= Enum.HumanoidStateType.Physics
		humanoid:ChangeState(setEnabled and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp)
		character.Animate.Disabled = setEnabled
		
		if setEnabled then
			for _,v in pairs(humanoid:GetPlayingAnimationTracks()) do
				v:Stop(0)
			end
		end
	end
end, false, Enum.KeyCode.R)

Show me your full current code please.

local plr = game.Players.LocalPlayer

local char = plr.Character

local hum = plr.Character.Humanoid

dog = false

hum.HealthChanged:Connect(function()

if hum.Health <= 15 and dog == false then

dog = true

hum.WalkSpeed = 0

hum.JumpPower = 0

local setEnabled = hum:GetState() ~= Enum.HumanoidStateType.Physics

hum:ChangeState(setEnabled and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp)

char.Animate.Disabled = setEnabled

if hum.Health >= 39 and dog == true then

dog = false

hum.WalkSpeed = 8

hum.JumpPower = 40

hum:ChangeState(Enum.HumanoidStateType.GettingUp)

char.Animate.Disabled = false

end

end

wait()

end)
local char = script.Parent
local hum = char.Humanoid

local ragDolled = false

hum.HealthChanged:Connect(function()
	if hum.Health <= 15 and ragDolled == false then
		ragDolled = true
		hum.WalkSpeed = 0
		hum.JumpPower = 0
		local setEnabled = hum:GetState() ~= Enum.HumanoidStateType.Physics
		hum:ChangeState(setEnabled and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp)	
		char.Animate.Disabled = setEnabled
		if setEnabled then
			for _,v in pairs(hum:GetPlayingAnimationTracks()) do
				v:Stop(0)
			end
		end
	end
	if hum.Health >= 39 and ragDolled == true then
		ragDolled = false
		hum.WalkSpeed = 8
		hum.JumpPower = 40
		hum:ChangeState(Enum.HumanoidStateType.GettingUp)
		char.Animate.Disabled = false
	end
end)
3 Likes

Oh yes! It works, oh my goodness how did you do it?

Well you seemed to have an error in your code, your humanoid variable was called ‘hum’ but in the for loop you called a function on an unknown variable named ‘humanoid’. Please mark my code as the solution and make sure to provide any errors that are shown in output from the code next time please, thanks!

1 Like

Thank you so much, but the only thing I can say is, there were no output errors for me.

Can you mark my code as the solution please so we know the forum post is solved, thanks!

I click it and its not working?