Problem with randomly dying

I have a game and dealing with a problem where humanoid would die when they werent supposed because of smth that wasnt related to my scripts

it would happen when ragdolled so it might be about humanoid states?

char.isragdoll.Changed:Connect(function(v)
		if v then
			startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
			if hum:GetState() == Enum.HumanoidStateType.Dead then
				return
			end
			startergui:SetCore("ResetButtonCallback", false)
			hum:ChangeState(Enum.HumanoidStateType.Physics)
		else
			startergui:SetCore("ResetButtonCallback", true)
			hum:ChangeState(Enum.HumanoidStateType.GettingUp)
		end
	end)
hum.StateChanged:Connect(function(o, n)
		--to be sure char is physics when ragdolled
		if n == Enum.HumanoidStateType.Dead then
			return
		end
		if n ~= Enum.HumanoidStateType.Physics and char.isragdoll.Value then
			hum:ChangeState(Enum.HumanoidStateType.Physics)
		end
	end)

these are the only hum state related ragdoll part, which seem fine
is there any humanoid bugs or conditions that make it instantly die that can be the reason?

I am gonna cut it short now. if more context is needed I can show it too

2 Likes