Humanoid SetStateEnabled Problems

I’ve been trying to create a ragdoll on death with features such as, player body stays and decays after a minute, death animation and some other smaller features. I’ve been using Humanoid:ChangeState(Enum.HumanoidStateType.Physics) to make the ragdoll and hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false) to stop the player from getting up. Keep in mind that the player is dead. I don’t know if it’s engine bug but I’ve had to fight the script as it’s completely ignoring it and my other filters.

I’ve tried may fixes, such as running the script on the client and the server and done my research online to find other people having similar-ish problems from years ago.

Pic of my console
Console

Local Script

local Ragdolls = workspace:WaitForChild("Ragdolls")

for _,v in pairs(Ragdolls:GetChildren()) do
	local hum = v:FindFirstChild("Humanoid")
	
	hum:SetStateEnabled(Enum.HumanoidStateType.Physics, true)
	hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
	hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
	hum:SetStateEnabled(Enum.HumanoidStateType.Running, false)
	hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
	hum:ChangeState(Enum.HumanoidStateType.Physics)
	
	hum.StateChanged:Connect(function(oldstate, newstate)
		print(oldstate,newstate)
		hum:SetStateEnabled(Enum.HumanoidStateType.Physics, true)
		hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
		hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
		hum:SetStateEnabled(Enum.HumanoidStateType.Running, false)
		hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
		hum:ChangeState(Enum.HumanoidStateType.Physics)
		print(hum:GetState())
	end)
end

Even after all of this, the player is trying to get up (as seen above in the console).

If anyone has any alternatives or fixes, please let me know.

I used a local script in the StarterCharacterScripts, and using almost your identical code
(Obviously making it so the ragdoll is script.Parent and removing the for _, v), in testing I’m using an R15 rig and all it prints out is “Enum.HumanoidStateType.Running Enum.HumanoidStateType.Physics”, and “Enum.HumanoidStateType.Physics”. All it does is lay there on the ground with regular animations but can’t jump or move really.

From what I just tested, it works in a local script, but not server.

That’s really weird. When I tried on my client script it still tried to get up and at this point I’ve given up and have been using another method. I just set the character to platform stand and added collider parts for each main body part. This seams to work just as good or if not better than my original method.