We use cookies on this site to enhance your user experience

Humanoid State Change Detector

Humanoid State Change Detector

Sep 07 2018, 2:15 AM PST

When a humanoid state changes for the Players/LocalPlayer, the code below prints whether the state has been enabled or disabled.

This code should work as expected when placed in a LocalScript.

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:wait()
local humanoid = character.Humanoid

humanoid.StateEnabledChanged:Connect(function(state, enabled)
	if enabled then
		print(state.Name.." has been enabled")
	else
		print(state.Name.." has been disabled")
	end
end)