Ragdoll Script not working properly

So, im making a ragdoll script for my game, and i made it so player ragdoll when his health is less than 1, so he will be ragdolled and won’t trigger Humanoid.Died at the same time. Basically like “Knocked Down” but able to stand up.
I couldn’t find anything related to it on devforum, so im asking this question.
I made it so when player heals to 15 health, his character should stand up, but the character just lays on the ground and plays animations without standing up. I think the issue is somehow connected with GettingUp state, but im not sure. So, here is the script, local script and video of what happens:

--Script in StarterCharacterScripts
local hum = script.Parent:WaitForChild("Humanoid")
local value = Instance.new("BoolValue",script.Parent)
value.Name = "IsKnocked"
value.Value = false
value:GetPropertyChangedSignal("Value"):Connect(function()
	print(value.Value)
	--hum = script.Parent:FindFirstChild("Humanoid")
	--hum.PlatformStand =true
	if value.Value == true then
		hum:ChangeState(Enum.HumanoidStateType.Physics)
		hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
		hum.AutoRotate = false
		script.Parent.Animate.Disabled = true
		for _,v in pairs(hum:GetPlayingAnimationTracks()) do
				v:Stop(0)
		end
		for i,v in pairs(script.Parent:GetDescendants()) do
			if v:IsA("Motor6D") then
				local ball = Instance.new("BallSocketConstraint",v.Parent)
				ball.TwistLimitsEnabled = false
				ball.TwistLowerAngle = 30
				ball.TwistUpperAngle = 30
				ball.LimitsEnabled = true
				ball.UpperAngle = 25
				local att0 = v.Part0:FindFirstChild("RagAtt1") or Instance.new("Attachment",v.Part0)
				local att1 = v.Part1:FindFirstChild("RagAtt2") or Instance.new("Attachment",v.Part1)
				att0.Name = "RigAtt1"
				att1.Name = "RigAtt2"
				att0.CFrame = v.C0
				att1.CFrame = v.C1
				ball.Attachment0 = att0
				ball.Attachment1 = att1
				v.Enabled = false
			end
		end
	else
		--hum:ChangeState(Enum.HumanoidStateType.None)
		hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
		hum.AutoRotate = true
		hum.AutoRotate = false
		script.Parent.Animate.Disabled = false
		for i,v in pairs(script.Parent:GetDescendants()) do
			if v:IsA("Motor6D") then
				v.Enabled = true
			elseif v:IsA("BallSocketConstraint") then
				v:Destroy()
			end
		end
	end
end)
hum.HealthChanged:Connect(function(newH)
	if newH <= 1 then
		value.Value = true
	elseif newH >= 15 then
		value.Value = false
	end 
end)
--LocalScript, same location as server script
repeat wait() until script.Parent:FindFirstChild("IsKnocked")
local val = script.Parent:FindFirstChild("IsKnocked")
local hum = script.Parent:WaitForChild("Humanoid")
val:GetPropertyChangedSignal("Value"):Connect(function()
	if val.Value == true then
		--local hum = script.Parent:FindFirstChild("Humanoid")
		--hum.PlatformStand =true
		hum:ChangeState(Enum.HumanoidStateType.Physics)
		hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
		hum.AutoRotate = false
		script.Parent.Animate.Disabled = true
		for _,v in pairs(hum:GetPlayingAnimationTracks()) do
			v:Stop(0)
		end
	else
		--hum:ChangeState(Enum.HumanoidStateType.None)
		hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
		hum.AutoRotate = true
		script.Parent.Animate.Disabled = false
		for i,v in pairs(script.Parent:GetDescendants()) do
			if v:IsA("Motor6D") then
				v.Enabled = true
				print("Enabled Motor6D")
			elseif v:IsA("BallSocketConstraint") then
				v:Destroy()
				print("Deleted BallSocket")
			end
		end
	end
end)

and the video: https://gyazo.com/2e419854ca5028b686ce0a8d04713241