Humanoid State Type

I am trying to find the player’s statetype of running, so I can put there death at 0

-- 
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
	
	local player = game.Players.LocalPlayer
	local Char = player.Character
	local Humanoid = Char.Humanoid 
	
	if Humanoid:GetState() == Enum.HumanoidStateType.Running then
		print("Player is running")
	end
	
	
	
end)

Humanoid:GetState() returns an enum of the humanoids current state.

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

I know, is it a wrong solution? for my problem?

No, that’s the correct way to get the HumanoidStateType, there are other ways though too. For example, the Humanoid.StateChanged event is fired whenever the humanoid’s state changes. The new state is passed to any function connected to the event.

https://developer.roblox.com/en-us/api-reference/event/Humanoid/StateChanged

What’s the problem with your code, like if you have any errors.

The problem is that the server isn’t finding the state that the humanoid is in, i.e when I run my code, and start running, the print won’t go through, and I don’t have any errors.

You do have to use the statechanged function inherited from humanoid to acess the current HumanoidStateType I do believe. So @Limited_Unique did provide you with the correct information.

Thank you guys for your solutions, I tried them but It didn’t work for me, but I came up with another soloution, thanks yall

I’m late but for anyone reading and needing help, here’s the correct way to use GetState().

if Humanoid:GetState(Enum.HumanoidStateType.Running) then
	print("Player is running")
end

You must provide the HumanoidStateType for GetState().

6 Likes