How to Check Current HumanoidStateType?

Hello! As the title says, is there any way I can check the current state of the HumanoidStateType? I have a ragdoll system and I don’t want to Ragdoll a player when they are already Ragdolled.

Here is my Ragdoll script.

local RagdollEvent = game.ReplicatedStorage:WaitForChild("SendRagdoll")
local localPlayer = game.Players.LocalPlayer


RagdollEvent.OnClientEvent:Connect(function(plr)
	if localPlayer == plr then
		local character = plr.Character
		local humanoid = character.Humanoid
		local setEnabled = humanoid:GetState() ~= Enum.HumanoidStateType.Physics
		humanoid:ChangeState(setEnabled and Enum.HumanoidStateType.Physics)
		character.Animate.Disabled = setEnabled

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

Thanks!

1 Like

https://developer.roblox.com/en-us/api-reference/function/Humanoid/GetState